Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

UPDATE SQL CE Server via DataAdapter

WaterboyVBWaterboyVB Posts: 1Member
Hi All,

I have an issue which I have been trying to resolve for a couple of days. I am trying to update the SQL CE Server (which is in my project) with the changes that have been made to my dataset.

Code:

Dim myConn As SqlCeConnection = New SqlCeConnection(My.Settings.db_Database_Application_ConnectionString)

Dim myDataAdaptor As New SqlCeDataAdapter

Dim mySQLCommandUpdate As SqlCeCommand = New SqlCeCommand("UPDATE tblTutors SET Password = 'pass'", myConn)

Dim mySQLCommand As SqlCeCommand = New SqlCeCommand("SELECT * FROM tblTutors", myConn)

Dim myDataset As DataSet = New DataSet

myConn.Open()

myDataset.Clear()

myDataAdaptor.SelectCommand = mySQLCommand
myDataAdaptor.UpdateCommand = myConn.CreateCommand
myDataAdaptor.UpdateCommand.CommandText = ("UPDATE tblTutors SET Password = 'password'")

mySQLCommandUpdate.ExecuteNonQuery()

myDataAdaptor.Fill(myDataset, "tblTutors")

DataGridView1.DataSource = myDataset
DataGridView1.DataMember = "tbltutors"

myDataAdaptor.Update(myDataset, "tbltutors")

myConn.Close()

The changes seem fine when displaying the data in the DataGridView however the changes have not been made to the SQL CE Server itself.

Can anyone spot where I am going wrong here?

Any help is much appreciated.
Sign In or Register to comment.