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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

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…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

695 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