Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / April 2006

Tip: Looking for answers? Try searching our database.

Return a parameter count from a SQL Stored Procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
goldbond_8@hotmail.com - 03 Apr 2006 21:49 GMT
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?
Jim Hughes - 03 Apr 2006 23:30 GMT
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.

>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
[quoted text clipped - 20 lines]
> Does anyone know how to retrieve a count of parameters from a Stored
> Procedure?
Robbe Morris [C# MVP] - 04 Apr 2006 02:23 GMT
.DeriveParameters

Check out the source code for this ADO.NET Code Generator.

http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp

Signature

Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp

>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
[quoted text clipped - 20 lines]
> Does anyone know how to retrieve a count of parameters from a Stored
> Procedure?
goldbond_8@hotmail.com - 04 Apr 2006 16:25 GMT
Thanks Robbe

The .DeriveParameters worked perfectly.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.