Return a parameter count from a SQL Stored Procedure

G

goldbond_8

I would like to use ADO.Net to connect to a Stored Procedure in SQL
Server and return a count of parameters from it. I was able to do this
using ADO and VB 6 using the following code:

' m_objConn is a database connection

Set m_objCmd2.ActiveConnection = m_objConn
m_objCmd2.CommandText = "TestSP"
m_objCmd2.CommandType = adCmdStoredProc
'Assign to var
m_iSPCount = m_objCmd2.Parameters.Count

When I try it with VB.Net, my count is always 0

m_objConn.Open()
Dim objCMD As SqlCommand = New SqlCommand()
objCMD.Connection = m_objConn
objCMD.CommandText = "TestSP"
objCMD.CommandType = CommandType.StoredProcedure
'Assign to var
Dim icount As Integer = objCMD.Parameters.Count

Does anyone know how to retrieve a count of parameters from a Stored
Procedure?
 
J

Jim Hughes

You can reference ADOX in your VB.Net code and use it to query parameters.
ADO.Net does not have that functionality.

My personal preference is to use a code generation tool like
www.CodeSmith.com to create my stored proc wrappers instead of reinventing
the wheel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top