z3n

Hi,
How do i update a dataset without filling it over with a dataAdaper
I get the connection from a Module(So it works fine) :-)

My Code :

Forms Load Event :

da.SelectCommand = cmd
da.InsertCommand = cmd
da.UpdateCommand = cmd
da.DeleteCommand = cmd


Button Click Event :

cmd.CommandText = "SELECT * FROM tblClients"

da.Fill(ds, "tblClients")

cmd.CommandText = "INSERT INTO tblClients (ClientName,ClientPassword,ClientContact) VALUES ('Pete','PetePass','6313441')"

da.Update(ds, "tblClients")

MsgBox(ds.Tables("tblClients").Rows.Count)


tblClients is emty from the beginning.
The msgbox returns 0 (no update done to the ds)
After the (INSERT INTO) I want to update that info to the dataset without filling it again or building datarows to add later on like ds.Tables("Table").rows.add(datarow)

Is there a way to do this

TIA








Re: .NET Framework Data Access and Storage Updating Dataset

Bappi

The data adapter Update method doesn't fire unless and untill there is any change in Dataset. So calling the DataAdapter's update method doesn't make any difference. So you need to first add the data in the DataTable then you can update. Or you can call DataCommand ExecuteNonQuery method to perform the task.




Re: .NET Framework Data Access and Storage Updating Dataset

z3n

Thanx for the reply.

The dataset is now updated with new data. How do i save that changes back to my access db
Running a sqlcommand seems to be a long and painfull method since the data is saved under various tables in the dataset.

Is there a way to save it without a command

TIA




Re: .NET Framework Data Access and Storage Updating Dataset

Bappi

u can try using stored procedure. But the performance may not vary signaficantly. Also poor database design also may cause poor performance if two many indexes are defined.