In classic ADO, I would use the adocommand.parameters.refresh method to return the list of arguments expected by my stored procedure. Is there a way of doing that with the sqlCommand object in .net?
Printable View
In classic ADO, I would use the adocommand.parameters.refresh method to return the list of arguments expected by my stored procedure. Is there a way of doing that with the sqlCommand object in .net?
Check out this thread:
http://www.vbforums.com/showthread.p...hreadid=294922
you would use DeriveParameters command of the CommandBuilder object ...
VB Code:
Private Overloads Function DiscoverSpParameterSet(ByVal connection As System.Data.SqlClient.SqlConnection, _ ByVal spName As String, _ ByVal includeReturnValueParameter As Boolean) As System.Data.SqlClient.SqlCommand If (connection Is Nothing) Then Throw New ArgumentNullException("connection") If (spName Is Nothing OrElse spName.Length = 0) Then Throw New ArgumentNullException("spName") Dim command As New System.Data.SqlClient.SqlCommand(spName, connection) Dim discoveredParameters() As SqlParameter command.CommandType = CommandType.StoredProcedure OpenConnection(connection) SqlCommandBuilder.DeriveParameters(command) If Not includeReturnValueParameter Then command.Parameters.RemoveAt(0) End If Dim i As Integer For i = 0 To command.Parameters.Count - 1 command.Parameters(i).Value = DBNull.Value Next Return command End Function