|
-
Jul 31st, 2007, 01:31 PM
#1
Thread Starter
Hyperactive Member
Execute Stored Procedure from VB
This seems like such a simple thing I can not believe how much trouble I am having finding a sample. All I want to do is run a StroredProcedure in my VB.Net app. Can someone point me to a sample.
Everything I have found is returning results. All I want to do is run the procedure.
-
Jul 31st, 2007, 01:32 PM
#2
Re: Execute Stored Procedure from VB
In waht database? Just run the prodcure and don't set the return to anything?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jul 31st, 2007, 01:44 PM
#3
Re: Execute Stored Procedure from VB
Sounds like this example will be what you need. Just dont use the parameter as you dont need t retunr anything.
http://samples.gotdotnet.com/quickst...OutParams.aspx
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 1st, 2007, 07:19 AM
#4
Thread Starter
Hyperactive Member
Re: Execute Stored Procedure from VB
This is what if ended up with and it seems to work fine. However I am wondering if there is something that I can add that will tell me the procedure finished the task?
Code:
Dim cn As SqlConnection = New SqlConnection
cn.ConnectionString = Con
cn.Open()
Dim cmd As SqlCommand = New SqlCommand("sp_InsertInv", cn)
cmd.CommandType = CommandType.StoredProcedure
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & _
ex.Source, "Data Error", MessageBoxButtons.OK)
End Try
Last edited by FastEddie; Aug 1st, 2007 at 07:25 AM.
-
Aug 1st, 2007, 08:30 AM
#5
Re: Execute Stored Procedure from VB
if you don't get the error message box... then it ran..
-tg
-
Aug 1st, 2007, 02:24 PM
#6
Re: Execute Stored Procedure from VB
If you wanted to get fancy, you could modify your sp to return the number of records affected.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|