passing variables to a stored proceedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I am using a SQL stored proceedure and have it in the command text of a data adapter that I set up using the wizard. The proceedure is expecting to string inputs, ALTER PROCEDURE dbo.procedure (@tmp as VARCHAR(10), @TMP1 as VARCHAR(10)). just wondering how to do this? I have not created a data set yet so am thinking I will need to do so. Also the procedure will return a record set object that I will want to display part or all of on the web form. Do I bind this object or display its results on a data grid, if so how? Thanks Paul.
 
Paul,
If you setup the DataAdapter using the DataAdapter Configuration Wizard, you
don't have to do anything else to execute the stored procedure--except fill
in the Value property of the Parameters the wizard created for you before
you execute Fill. The procedure returns a resultset (not a Recordset) that
contains a rowset. When you use the Fill method, you point to an ADO.NET
DataSet object. You then bind that DataSet object to the DataSource of the
control you want to use to show the data (typically a DataGrid control).
Next, execute me.DataBind to complete the binding process.
I suggest looking through the copious online help files in Visual Studio
..NET or in one of the wealth of books on the subject--even mine.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Paul said:
Hi I am using a SQL stored proceedure and have it in the command text of a
data adapter that I set up using the wizard. The proceedure is expecting to
string inputs, ALTER PROCEDURE dbo.procedure (@tmp as VARCHAR(10), @TMP1 as
VARCHAR(10)). just wondering how to do this? I have not created a data set
yet so am thinking I will need to do so. Also the procedure will return a
record set object that I will want to display part or all of on the web
form. Do I bind this object or display its results on a data grid, if so
how? Thanks Paul.
 
Look at SqlParameter. You can attach an array of these to a SqlCommand.

You can specify parameters direction also.
 
Also I do not see the value property of the parameters the wizard should have created, is this in the properties window of the data adapter? Thanks Paul.
 
See www.betav.com for details.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Each Parameter object has a Value property--it's just a matter of finding it
in the maze of objects and collections. For more examples, see my article on
handling parameters.
http://www.betav.com/msdn_magazine.htm.

mySqlDataAdapter.SelectCommand.Parameters("ParameterWanted").Value = "Fred"


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Paul said:
Also I do not see the value property of the parameters the wizard should
have created, is this in the properties window of the data adapter? Thanks
Paul.
 
Back
Top