Solved

How do I call a stored procedure from my database to run in my form that already has a table adpater on it?

Posted on 2006-06-12
4
176 Views
Last Modified: 2010-04-23
I have VS2005.
I have a form that was created through the datasource wizard, dropping the proper objects onto my form. The form is now  connected to my database through the table adapter, bindingsource, and bindingnavigator that it created. This all works fine. Is there a way to use this table adapter to call a stored procedure from my database? I can't seem to get it to work. I really don't want to have to code all the objects on the form if I don't have to, to save time. I'm hoping there is way to use the existing table adpater.
The code I'm trying to use is

dim Com as new SqlClient.SqlCommand
Com.CommandType =  CommandType.StoredProcedure
Com.CommandText = "StoredProcedure"

Thanks
0
Comment
Question by:grouchyfd
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
vb_jonas earned 500 total points
Comment Utility
Dim Com as new SqlClient.SqlCommand
Com.Connection = TableAdapter1.Connection ' from the designer object
Com.CommandType =  CommandType.StoredProcedure
Com.CommandText = "StoredProcedure"

Com.Connection.Open()
Com.ExecuteNonQuery()
Com.Connection.Close()

no?
0
 

Author Comment

by:grouchyfd
Comment Utility
Excellent!!! I have this now working. The points are yours, vb jonas. This updates the table properly. Now I'm trying to get the textboxes on my form to show the changes when the procedure is fired. I can't seem to get it.

Dim Received as integer
Received = Textbox1.Text
Received = Com.ExecuteScalar
Textbox1.Text = Rec
0
 
LVL 12

Expert Comment

by:vb_jonas
Comment Utility
Great! :-)

and you have filled your dataset again, TableAdapter1.fill(DataSet1)?
0
 

Author Comment

by:grouchyfd
Comment Utility
Thank you for helping me through a "Duh" type moment on the tableadapter.fill method.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now