?
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
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
vb_jonas earned 2000 total points
ID: 16886571
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
ID: 16886976
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
ID: 16887047
Great! :-)

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

Author Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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