Wednesday, March 28, 2012

Passing multiple parameters to stored procedure using SqlDataSource

Hi,

I have a stored procedure that takes 3 parameters. I am using a sqldatasource to pass the values to the stored procedure. To better illustrated what I just mention, the following is the code behind:

SqlDataSource1.SelectCommand = "_Search"
SqlDataSource1.SelectParameters.Add("Field1", TextBox1.Text)
SqlDataSource1.SelectParameters.Add("Field2", TextBox2.Text)
SqlDataSource1.SelectParameters.Add("Field3", TextBox3.Text)
SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure

GridView1.DataSourceID = "SqlDataSource1"
GridView1.DataBind()
MsgBox(GridView1.Rows.Count)

It doesn't return any value. I am wondering is that the correct way to pass parameters to stored procedure?

Stan

Hope this will help:

http://www.codeproject.com/cs/database/CSCodeBuilder.asp

BTW: there are many posts explaining this, just use the "Search".

Good luck.

|||

Thanks. That gives me a clue and helps me to solve my problem.

No comments:

Post a Comment