Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with deleting a datarow in an SQL database using VB.NET.

Status
Not open for further replies.

mjs84

Aerospace
Aug 20, 2003
27
I am a newbie with vb.net and SQL and I have run into a bit of a snag.

I have written code to manipulate an SQL database. I have routines to connect, read, query, edit, add, delete and update data to the database.

Everything seems to be working just fine, except the delete function. I am not getting any errors - the data just does not get deleted from the database.

The method I'm employing is declaring a dataset and a data adapter. I am filling the dataset, (mydataadapter.fill(mydataset,tbl)), then updating the database thru the data adapter. When I do the delete function (rows.remove), it removes the line from the dataset, but the database does not get updated. The update function works when I add or edit data, just not when I delete data.

I have a sqldataadapter control on the form. The properties page for this control has a the following delete command:

DELETE FROM Emp01
WHERE (EmpID = @Original_EmpID) AND (FName = @Original_FName OR
@Original_FName IS NULL AND FName IS NULL) AND (LName = @Original_LName OR
@Original_LName IS NULL AND LName IS NULL)


Any help would definitely be appreciated - I am really struggling with this.

Thanks in advance.

 
Replies continue below

Recommended for you

To anyone interested.

I did find the solution to my problem - I was using the wrong delete command. I used the:
mydataset.tables(tablename).rows.remove command and needed the
mydataset.tables(tablename).rows.delete command.

-mjs84
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor