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
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
203 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calling web service and its methods dynamically 2 73
VS.net 2010 11 48
VB.NET (2008) - Refactoring Question 2 23
VB: Convert 2 dates to specific format 24 51
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 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