I'm looking for good code examples on updating and/or inserting new records into a SQL database. I've written an App for writing to an Acess Database but now am trying the same with SQL and am getting nowhere. I'm working with a Dataset, which I can insert new rows into fine and the changes will display in a datagrid on my form but the changes do not take effect in the SQL table. If I could get an example with just 1 column I could go from there.
Below is the code I use to update the datagrid.
Dim insertcmd As SqlCommand
insertcmd = New SqlCommand("INSERT INTO Test (ShiftID, SupervisorID) VALUES (@ShiftID, @SupervisorID), myConn")
insertcmd.Parameters.Add("@ShiftID", SqlDbType.Char, 10, "ShiftID")
insertcmd.Parameters.Add("@SupervisorID", SqlDbType.Char, 10, "supervisorID")
myDA.InsertCommand = insertcmd
Below is the code I use to update the datagrid.
Dim insertcmd As SqlCommand
insertcmd = New SqlCommand("INSERT INTO Test (ShiftID, SupervisorID) VALUES (@ShiftID, @SupervisorID), myConn")
insertcmd.Parameters.Add("@ShiftID", SqlDbType.Char, 10, "ShiftID")
insertcmd.Parameters.Add("@SupervisorID", SqlDbType.Char, 10, "supervisorID")
myDA.InsertCommand = insertcmd