I have an asp.net website that I have created for employees so submit their timesheets online. The application already exists as a VB.NET Windows Form Application that has a strongly typed dataset, so writing and completing all of these sql commands manually is very different for me, and I'll admit, I'm struggling
.There are rows in a table called Calendar. If there is previously submitted data, the previous data gets deleted and the new data added. I can query and insert rows fine, but it's like the delete command doesn't actually want to commit. If I requery after deleting, using the same sql connection, it returns that there are no rows (they have been deleted), but if I close the connection and then open again and requery, they are still there.This is my current code for deleting the rows: Dim sql As String Dim sstart As DateTime = GetFirstDOW(Calendar1.SelectedDate) Dim mycommand As SqlCommand Dim thisTransaction As SqlTransaction Using myConnection As New SqlConnection(connString) sql = "DELETE FROM Calendar WHERE (UserID = N'" & empID & "') AND (StartDate >= CONVERT(DATETIME, '" & sstart.Year & "-" & sstart.Month & "-" & sstart.Day & " 00:00:00', 102)) AND (StartDate <= CONVERT(DATETIME, '" & sstart.AddDays(6).Year & "-" & sstart.AddDays(6).Month & "-" & sstart.AddDays(6).Day & " 00:00:00', 102))" mycommand = New SqlCommand(sql, myConnection) mycommand.Connection.Open() thisTransaction = myConnection.BeginTransaction() mycommand.Transaction = thisTransaction mycommand.ExecuteNonQuery() thisTransaction.Commit() mycommand.Connection.Close() End Using
Any help you can provide here??