sql server stored procedure : MyDataset has changed, i acceptedchanges, cant update it back to database,1st timer
Posted on 2004-10-08
hi this is the first time i use stored procedures in .net
i created the select,insert,update &Delete commands via a sqldataadapter. (all 3 options ticked in advanced options on adapter)
vb saved the procedures on the database
my select statement gets passed 1 parameter
this is how i fill my dataset
dim cmd As New SqlCommand("MySelect", mySqlConnection)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@MyValue", SqlDbType.VarChar).Value = MyValue
Dim da As New SqlDataAdapter(cmd)
I can confirm that MyDataset1 gets filled correctly , as "c:\proc1.xml" contains all the unmodified data.
now i change some of the values in the dataset e.g.
there is a field called "MyField" and i change the value in it from <NULL> to "5000"
now i tried a few different approaches to update the dataset back to the database , and this is what it comes down to
Dim cmdUpdate As New SqlCommand("MyUpdate", mySqlConnection)
cmdUpdate.CommandType = CommandType.StoredProcedure
da.UpdateCommand = cmdUpdate
now i have a look and see that the values in "c:\proc2.xml"
are 100% correct, the values have changed. the code runs through fine without any errors.
but NO changes are made in the physical database.
now i tried to comment out the first line of the last pasted section : MyDataset1.MyTable.AcceptChanges()
now it says that i need to enter parameters for all the @Fields in the database.
all data is drawn from only 1 table in the database
i dont know how to update back to the dataset, any help please!