Is this method all right ?

rHasan

Active member
Joined
Jan 10, 2007
Messages
43
Programming Experience
3-5
I've provided the Delete functionality in my form in this way -

VB.NET:
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] IsConnectionOpen() [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]OpenConnection()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]objCommand = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbCommand([/SIZE][SIZE=2][COLOR=#a31515]"Delete From Color[/COLOR][/SIZE][SIZE=2][COLOR=#a31515] Where Color[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]ID = "[/COLOR][/SIZE][SIZE=2] & Val(txtID.Text), objConnection)[/SIZE]
[SIZE=2]objCommand.ExecuteNonQuery()[/SIZE]
[SIZE=2]ShowData()[/SIZE]
[SIZE=2]CloseConnection()[/SIZE]
This system works, but is it all right to use? Does it have any drawback ?

Thnx!
 
Are you using datasets? if not, then this is fine.

If you are using datasets, then it is better to handle all data operations via the dataset where possible.
 
Does it have any drawback ?

Yup. If you have a datatable with deleted rows, youre going to have to get a list of all the deleted rows, then loop through them, putting each ones id into the textbox, then calling your function..

After developing your first few apps like this, you may come round to the wonderful functionality that microsoft have spent 5+ years developing.. At the moment youre still pretty much coding like this is VB6, which is fine, but that bit more long winded because VBN jsut isnt geared like that any more..
 
Back
Top