DataSource Controls :: Adding Parameters To Storedprocedure?

Jan 18, 2010

I am using ASP.NET 2.0 and C#, SQL Server 2005. I am passing parameter to a stored procedure. The parameter is the ProductId. I have 3 types of productId. ProductId 11,0,12.

If the ProductId is zero, I want to pass the productId as 11 to the parameter.

Is this correct way to perform:

[Code]....

View 4 Replies


Similar Messages:

Forms Data Controls :: Update Gridview With Different Storedprocedure Parameters?

Mar 27, 2011

I have gridview which takes data from storedprocedure with some in parameters.

How to change storedprocedure in parameter values for sqldata source and update gridview on button click?

View 4 Replies

DataSource Controls :: Programmatically Adding Parameters To SQLdatasource In Codebehind Using C#

Apr 1, 2011

I have a page called Page2.aspx and it is called by another page called Page1.aspx and Page1.aspx passes two parameters namely: Name and Category to Page2.aspx. Does anyone know why the following code from Page2.aspx is not working and it keeps giving an error message as follows: " You have declare the parameter @Username".

string Cat1;
string Name1;

[Code]....

View 2 Replies

DataSource Controls :: StoredProcedure Returning Zero Instead Of Value?

Feb 2, 2010

My stored procedure is returning zero....can anybody correct me....Stored Procedure -

[Code]....

Fucntion calling SP -

[Code]....

tell me where i went worng and correct procedure too....table hase 4 rows....so count should return 4..

View 8 Replies

C# - Adding Some More Parameters To The DataSource?

Dec 15, 2010

I have a GridView and I want to add some more parameters to the DataSource. One of the parameters is called symbols and is a DataTable, and I'm not sure how to add it. Here's my GridView:

<asp:GridView
ID="grdTrades"
runat="server"
DataKeyNames="tradeId"
DataSource="srcTrades"
EnablePersistedSelection="true"
AllowPaging="true"
AllowSorting="true"
PageSize = "10"
AutoGenerateColumns="false"

[Code]....

I did try and bind the data myself and removing the ObjectDataSource entirely but then the sorting and paging events weren't handled.

View 2 Replies

DataSource Controls :: Storedprocedure, Where Functie Only If The Number Is Not 0?

May 24, 2010

need a Stored Procedure with a where with 23 where items.But if a item is 0 then i should skip that selection.So i need something like the code below, but sadly that doesnt work... And 23x23=529 selections isn't a option for me.

[Code]....

select * from tblMatchData

View 2 Replies

DataSource Controls :: How To Insert Multiple Record IN Sql Using StoredProcedure

Feb 15, 2010

I am going to insert Multiple record IN sql using storedProcedure from gridview...

for this purpose i am using cell concatinating method and send whole gridview cell data in string variable.

i have tried xml document method or sending data in table through looping as well but didn't satisfy from both of them... b/c concatinating method required a delimeter for seperation(for which i have restrict the user from that sepereator ) and xml method required an extra file which is not a efficient approach .

View 7 Replies

DataSource Controls :: Passing Null To Storedprocedure Using Linq

Mar 31, 2010

I have a SP db.sp_GetProfitMatrix , it takes nullable integer parameters, for which I have a default . It refuses me when I try to pass a null value (the two date parameters are nullable in the Linq designer) I get {"Nullable object must have a value."} error. here is my code:

int? nlDt = null;
var pms =
from p
in db.sp_GetProfitMatrix( nlDt.Value, nlDt.Value)
select
new
{
p.Volume,
p.GrossSales,
p.NetSales,
p.COGS
};

View 4 Replies

DataSource Controls :: Building String To Pass Into StoredProcedure From CheckBoxList?

Jul 1, 2010

I have a CheckBoxList that I need to get the values from, concatenate, and pass into a stored procedure in SQL Server 2005 utilizing Visual Basic. Due to the way our data layer is I cannot use a SqlCommand object at this level.

I have no problem getting to the selected values in the CheckBoxList:

Dim selectedValue As New StringBuilder
For i = 0 To cblMethods.Items.Count -1
If cblMethods.Items(i).Selected Then
selectedValue.Append(cblMethods.Items(i).Text)
End If
Next

The problem is that I do not know how to list the values in such a way that my stored procedure will pull data:

SET @MethodNames ='GetWords','GetLetters'
SELECT * FROM TABLE WHERE method IN ( @MethodNames )
I've tried experimenting with apostraphes but cannot make it work:
selectedValue.Append("'''" + cblMethods.Items(i).Text + "''', "

View 2 Replies

DataSource Controls :: SqlDataSource Returning Nothing When A SelectParamter Value Is Passed To A StoredProcedure?

Jan 14, 2010

- When I execute my query within Enterprise Manager giving the "Country" parameter a value of US, it returns the expected records

- When I assigned that value either programmatically or within the SelectParameters of my SqlDataSource, no rows are returned at all...

I have this as a parameter in the sproc:

@Country char(2) = NULL

and the relevant WHERE clause entry is:

AND (@Country IS NULL OR a.CountryCode = @Country)

My SelectParameter is:

asp:Parameter Name="Country" />

I've tried adding the "DefaultValue" property set to "US" and also tried setting it as sds.SelectParameters[4].DefaultValue="US"

When I do either of these things I get no records returned...

View 2 Replies

How To Change [dbo].storedprocedure To [myusername].storedprocedure

Oct 29, 2010

I developed a website in my local machine using asp.net and sql.

View 10 Replies

DataSource Controls :: Use Is Null In Query Without Using Parameters For It Or Should Use Parameters For This Field Where Value Is NULL

Jan 21, 2010

here is my code for selectiong some records from db table

string strSql = "select * from mtblNBD where SentTo=@SentTo and InternalStatus Is NULL order by DeadLine desc";
SqlCommand com = new SqlCommand(strSql, con);
com.Parameters.Add("@SentTo", SqlDbType.NVarChar, 50).Value = (string)Session["uname"];

here I am using parameters for SenTo field but not for NULL so it is ok... or should I use parameters for this field where value is NULL , if yes then how can I use parameter for this

View 8 Replies

Forms Data Controls :: Trouble Adding Parameters To FormView's UpdateCommand?

Feb 15, 2010

I'd like to pull several NewValues from a FormView and write them to a database as part of the Update command.For some reason, I am unable to do this using the following code. Is there something I am missing?

[Code]....

View 2 Replies

DataSource Controls :: Add Parameters On Dataadapter?

Jun 23, 2010

How could I add parameters on dataadapter? I tried

[Code]....

But parameters is unknown for dataadapter.

View 4 Replies

DataSource Controls :: SqlDataSource With A Lot Of Parameters?

Sep 4, 2010

I have asked similiar question before where I have two control on the page header says "username" and "gender". User can select both the control or either one and the page will execute searching based on the criteria supplied. So if username supplied

SELECT * FROM [this_table] WHERE username = @username
and if gender supplied
SELECT * FROM [this_table] WHERE gender = @gender
and if both supplied
SELECT * FROM [this_table] WHERE username = @username AND gender = @gender

I know this sounds not very complicated but in my case, I am having like more than 10 controls up there. It is something likeusername, gender, age, date of brith, title, father name, frst name, last name, blur blur blur and it's a lot then I started to lost. if i were to use if else caluse on code-behind and produce query, it would end up writing a lot of if-else and if i use stored procedure (with if-else) then my stored procedure would contains a lot of if-else statement. I am fairly new to this concept and if I'm on the wrong track, please correct me. Is there any better way to save my hair without actually going through each
if-else statement to build the query ?p.s. I'm using GridView and SqlDataSource command to display the result back on .aspx page.

View 2 Replies

DataSource Controls :: Using Parameters For A Listview

Jun 4, 2010

I have webform with a listview control on it that uses 2 date values supplied by the user (via 2 text boxes) to dynamically set date range parameters for the datasource. The user enters two dates and clicks a button that runs the following code that sets the parameters:

[Code]....

This code works the first time the user clicks the button. But if they change the date values and try again, it only returns the result set from the first request. The parameters are not updated to the new values supplied by the user.

View 2 Replies

DataSource Controls :: Can Use If Else In Sqldatasource If Else Parameters

Oct 4, 2010

I am trying to check whether a username exists in my database before inserting the new row & display a message to the user if it does.

On my SqlDataSource my InsertCommand looks like this:

InsertCommand="IF NOT EXISTS (SELECT * FROM Users WHERE UserName = @UserName) BEGIN INSERT [Users] ([UserName], [FirstName], [LastName], [City], [State], [Country], [CompanyName], [Active], [PasswordHash]) VALUES (@UserName, @FirstName, @LastName, @City,
@State, @Country, @CompanyName, @Active, @PasswordHash) END"

This works as expected: If the username is unique, the row is created.

If the username already exists, the row is not added.

The problem is, if the row already exists, the insert is rejected but the user is not notified.

So my question is, is there a way I can notify the user?

Maybe something like: InsertCommand = "If Not Exists (select....) Begin Insert...Else Notify User Somehow End This is a basic database, I'm not using the built-in membership provider nor will be.

View 1 Replies

DataSource Controls :: Inserting Parameters?

Jan 10, 2010

I'm linking a form to sql database, As far as i know for textbox the code will be like this one below in VB:

dashDataSource.InsertParameters.Add("databaseColumName", NameOFTextBox.Text)

But what is the code for a drop down menu for countries list?

View 3 Replies

DataSource Controls :: No Value Given For One Or More Required Parameters?

Apr 13, 2010

I can't see what I've missed

Dim strSQL As String = _
"UPDATE [emailText] SET " & _
"[stdSubjectLine] = @subjLine, [stdBodyText] = @bodyText, " & _

[code]...

View 1 Replies

DataSource Controls :: Passing Parameters To ObjectDataSource

Aug 9, 2010

I followd Brian Orrell LINQ tutorial for paging/sorting and created a gridview bound to an ObjectDataSource through a method call which gets data from adatabase. My form includes two buttons with a textbox next to each one of them. I need to be able to populatte th egridview depending on the button that was pressed, I cannot figure out how signal my method which button was pressed.
[Code]....
[URL]

View 1 Replies

DataSource Controls :: Setting Parameters In ListView

Mar 17, 2010

I have a ListView that, among other things, in the EditItemTemplate, has a pair of related DropDownList controls, sort of a parent/child relationship. The selected value of the parent is used as a parameter for the SQL Datasource of the child. Outside of a control such as the ListView, this would be easy and I'd simply set up a ControlParameter for the SQL Datasource and life would be good. Within the DataList things are not quite so simple. My plan is to set the parameter of the child in the Selecting handler of its datasource. I have hard coded some values and this works the way I want it to. My problem is getting the "parent" value. I've got two theories on how to get this:

#1, I've tried instantiating the parent DropDownList but it is either not available at this point in the page life cycle or I just don't know the syntax to get at it from within the Selecting handler.

#2, I'm thinking I may have to grab the value from the underlying data for the ListViewRow that I am editing, but again, I do not know the object model well enough to get at those values.

Below is a code sample for option #1. As stated, setting the parameter works, but getting the value of the DropDownList does not.

View 5 Replies

DataSource Controls :: Sql Parameters - Not Listed In Dropdown

Oct 12, 2010

All control are not listed in dropdown when selecting a control for adding parameter to update query.

View 1 Replies

DataSource Controls :: How To LinqDataSource Date Parameters

Jun 15, 2010

I need to retrieve data using a date as an input parameter. I created a WhereParameter and passed in a date value that I know to exist in the database, but no data is returned. Heres my code

[Code]....

Ive passed in '02/06/2010' as the date, in the database, the Startdate column has several values of '2010-06-02 13:08:50.503' so I guess its not being found because of the time part. Whats the best way to make sure that I retrieve the correct data ? Im not concerned about the time at all, I just need all rows for 02/06/2010.

View 3 Replies

DataSource Controls :: Getting Sql Functions Parameters Into The C# Code

Apr 30, 2010

getting the Parameters declared in an sql function in the C# code. We can actually get the parameters from a Stored Procedure by giving SqlCommandBuilder.DeriveParameters

Similarly is there any way to get the Parameters from the SQL Function.

View 2 Replies

DataSource Controls :: Combining Two Parameters To One Column?

Jan 21, 2010

Is it possible in SqlDatasource Update command to combine two parameters to make a third?

[Code]....

this is what I need to do Combine First and Last names with a space between.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved