Deleted in dataset but not in the database..

cjaymcmeans

Well-known member
Joined
Jan 12, 2005
Messages
85
Programming Experience
3-5
im having trouble deleting records in my database.. i just started using vs.net...
i was successful in deleting rows in datasets.. my problem is that i want to delete the records also... i've used oledbcommands... command adapters but sadly i am yet to succeed in deleting the rows that i have deleted in the dataset in the database... hope you guys can help..
 
Hi,
What all u have to do is Just create the oledbParameter Object whose ParameterName will be same as that of Table's ID Column "@ID"........and specify all other fileds of Parameter like DataType,and in Value Parameter Just Pass Data Column Name i.e "ID"

Specify the DeleteCommand of Dataadapter and

call Adapter.Update() it will delete all the Records from DB which u have deleted From Datatable..............................

e.g
conSQLConnection = New SqlConnection(GlobalData.Applevel.ConnectionString)

comSQLCOmmand =
New SqlCommand("Delete From ABC WHERE ID = @ID", conSQLConnection)

comSQLCOmmand.CommandType = CommandType.Text
parSQLDelete = New SqlParameter("@ID", SqlDbType.SmallInt, 2,"ID")

comSQLCOmmand.Parameters.Add(parSQLDelete )

daSQLAdapter =
New SqlDataAdapter()

daSQLAdapter.DeleteCommand = comSQLCOmmand

daSQLAdapter.Update(dsDataSource)



I hope this will Help u...............................

Reagrds,
Ritesh




 
cjaymcmeans said:
im having trouble deleting records in my database.. i just started using vs.net...
i was successful in deleting rows in datasets.. my problem is that iwant to delete the records also... i've used oledbcommands... commandadapters but sadly i am yet to succeed in deleting the rows that i havedeleted in the dataset in the database... hope you guys canhelp..

use the oledbcommandbuilder and pass the adapter to update your database.
 
Back
Top