470,566 Members | 1,400 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,566 developers. It's quick & easy.

Passing a parameter to DataAdapter

I have an asp.net application in C# and i'm trying to call
a stored procedure with a parameter. When i run the web
app i get this message:

Procedure 'sp_loadCustByID' expects
parameter '@CustomerID', which was not supplied.

How do i pass the parameter to my dataAdapter and into my
dataset. the parameter is entered by the user in a text
field.

my stored procedure looks like this:
CREATE PROCEDURE sp_loadCustByID
(@CustomerID varchar (20))

AS
select * from [MyTestDB].[dbo].[Customers]
where( [CustomerID] = @CustomerID)
GO

my C# looks like this:

//create a data adapter
SqlDataAdapter da =
sqlDataAdapter1;

//get parameter
sqlCommand1.CreateParameter
().Value = customerid.Text.ToUpper();

//create a data set and fill it by
calling Fill method
DataSet ds = new DataSet("Cust");
da.Fill(ds,"Customers");
//attach data set's default view
to the data grid control
DataGrid1.DataSource = ds;
DataGrid1.DataMember = "Customers";
DataGrid1.DataBind();
Jul 21 '05 #1
0 1952

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by JIM.H. | last post: by
reply views Thread by ZoeNeedsHelp | last post: by
2 posts views Thread by Tony Girgenti | last post: by
12 posts views Thread by dave_dp | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.