passing parameters

drmisko

New Member
How would I pass the parameters to a stored procedure when using <BR>ExecuteReader()?<BR><BR>thx in advance<BR>WhiteAn example:<BR><BR>OleDbConnection myConnection = new OleDbConnection(connectionString);<BR>OleDbCommand myCommand = new OleDbCommand("sp_GetAllButOneForum", myConnection);<BR><BR>OleDbParameter parameterID = new OleDbParameter("@ID", OleDbType.Integer, 4);<BR>parameterPostID.Value = http://aspmessageboard.com/archive/index.php/someLocalVariable;<BR>myCommand.Parameters.Add(parameterID);<BR><BR>// Execute the command<BR>myConnection.Open();<BR>OleDbDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConne ction);<BR><BR><BR>There ya go! You can have multiple parameters, of course. Just create them, and add them as shown above. Of course you can also use the SqlClient variant approach, as opposed to the OleDb approach used above (assuming you are using MS SQL Server 7.0+).<BR><BR>Happy Programming!My procedure actually has 2 parameters.And it gives an error that "parameters exists for this Procedure"<BR>
 
Back
Top