Error In My Delete Code

yaser95

Member
Joined
Jul 27, 2006
Messages
8
Programming Experience
1-3
I Have Error When I used This Code ..
My Error Inside
VB.NET:
[COLOR=#800000]"DELETE FROM thebank [/COLOR][SIZE=2][COLOR=#800000]WHERE id = ?;"[/COLOR][/SIZE][SIZE=2] & _
[/SIZE][SIZE=2][COLOR=#800000]"DELETE FROM Data WHERE id = ?;"[/COLOR][/SIZE]
See My Full Code Abou Delete
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] objCommand [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] OleDbCommand = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbCommand()
[/SIZE][SIZE=2][COLOR=#008000]' Set the Command object properties...
[/COLOR][/SIZE][SIZE=2]objCommand.Connection = cn
objCommand.CommandText = [/SIZE][SIZE=2][COLOR=#800000]"DELETE FROM thebank "[/COLOR][/SIZE][SIZE=2] & _
[/SIZE][SIZE=2][COLOR=#800000]"WHERE id = ?;"[/COLOR][/SIZE][SIZE=2] & _
[/SIZE][SIZE=2][COLOR=#800000]"DELETE FROM Data WHERE id = ?;"
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' Parameter for the title_id field...
[/COLOR][/SIZE][SIZE=2]objCommand.Parameters.AddWithValue _
([/SIZE][SIZE=2][COLOR=#800000]"?"[/COLOR][/SIZE][SIZE=2], BindingContext(MyDataView).Current([/SIZE][SIZE=2][COLOR=#800000]"id"[/COLOR][/SIZE][SIZE=2]))
[/SIZE][SIZE=2][COLOR=#008000]' Open the database connection...
[/COLOR][/SIZE][SIZE=2]cn.Open()
[/SIZE][SIZE=2][COLOR=#008000]' Execute the SqlCommand object to update the data...
[/COLOR][/SIZE][SIZE=2]objCommand.ExecuteNonQuery()
[/SIZE][SIZE=2][COLOR=#008000]' Close the connection...
[/COLOR][/SIZE][SIZE=2]cn.Close()
[/SIZE]

 
i do not have any problem with Parameters ..
My Problem is ..
i can't delete from two Table by one Query like My book .
Thanks in Advance
 
You have to make two calls.... once the ; is encountered, that terminates the SQL Query..... so you will need to make two calls, one for one table and another for the other table.

-tg
 
Back
Top