tableadapter & stored procedure

thomas008

Well-known member
Joined
Feb 17, 2009
Messages
54
Location
Belgium
Programming Experience
Beginner
Hi

I'm trying to use stored procedures as select,update,delete and insertcommand for the tableadapter. Is it posible to do this. I tried the following

VB.NET:
myCommand.CommandText = updatecommand
myCommand.CommandType = CommandType.StoredProcedure
myAdapter.UpdateCommand = myCommand
myCommand.CommandText = deletecommand
myCommand.CommandType = CommandType.StoredProcedure
myAdapter.DeleteCommand = myCommand
myCommand.CommandText = insertcommand
myCommand.CommandType = CommandType.StoredProcedure
myAdapter.InsertCommand = myCommand

The commands seem to work only not the way they should!
When i Insert a record gets deleted and when i update a record gets inserted.
I can not figure out why because the commandnames are matching the SQL i want to place in them.

Does anyone have an idea?
 
Nevermind. I solved it. I just had to declare a new command each time or else it would be overwriten and all the commands would equal the last inserted command
 
er, yes..

But why are you doing this yourself?

You should be using the designer to do this. Open the dataset designer, click the tableadapter you want to edit and then in the properties window, select the sprocs you want to use. You have the added advantage that the designer will then populate the properties colelction for you
 
Back
Top