PLEASE PLEASE PLEASE someone help me.
i have a windows app that pulls data from a sql server box. i get all of the data fine. what i have setup is the user finds the record, presses a modify button, and another form opens as a dialog window, and the user types in the data they want to update the record. when they press done, it closes the form and passes the text entered back to the previous form (that shows records and has the dataadapter).
i then have it set to set the updatecommand and execute. but i get the nullreferenceexception error on my dataadapter.
i've tried all kinds of combinations and searched everywhere online, but i cannot find anything at all. please someone help.
Here is my load event code (just the part that matters):
myConn.Open()
myDA = New SqlClient.SqlDataAdapter("SELECT * FROM order, employee WHERE order.Employee_login = employee.username ORDER BY order_number", myConn)
cmdSql.Connection = myConn
cmdSql = New SqlCommand(sql, myConn)
cmdSql.CommandType = CommandType.StoredProcedure
myDA.UpdateCommand = New SqlCommand
myDA.UpdateCommand = cmdSql
myDA.Fill(myDS, "order")
And here is my code for my update procedure:
Public Sub setUpdate(ByVal WO As String, ByVal d1 As String, ByVal d2 As String, ByVal dateClose As String, ByVal EmplClose As String)
Dim sql As String
dateClose = Replace(dateClose, "AM", "")
dateClose = Replace(dateClose, "PM", "")
sql = "UPDATE order SET description = '" & d1 & "', description2 = '" & _
d2 & "', Date_time_closed = '" & dateClose & "',Empl = '" & EmplClose & "' WHERE order_number = " & _
WO & ";"
cmdSql = New SqlCommand(sql, myConn)
myDA.UpdateCommand = cmdSql
myDA.Update(myDS, "order")
myConn.Close()
End Sub
i have a windows app that pulls data from a sql server box. i get all of the data fine. what i have setup is the user finds the record, presses a modify button, and another form opens as a dialog window, and the user types in the data they want to update the record. when they press done, it closes the form and passes the text entered back to the previous form (that shows records and has the dataadapter).
i then have it set to set the updatecommand and execute. but i get the nullreferenceexception error on my dataadapter.
i've tried all kinds of combinations and searched everywhere online, but i cannot find anything at all. please someone help.
Here is my load event code (just the part that matters):
myConn.Open()
myDA = New SqlClient.SqlDataAdapter("SELECT * FROM order, employee WHERE order.Employee_login = employee.username ORDER BY order_number", myConn)
cmdSql.Connection = myConn
cmdSql = New SqlCommand(sql, myConn)
cmdSql.CommandType = CommandType.StoredProcedure
myDA.UpdateCommand = New SqlCommand
myDA.UpdateCommand = cmdSql
myDA.Fill(myDS, "order")
And here is my code for my update procedure:
Public Sub setUpdate(ByVal WO As String, ByVal d1 As String, ByVal d2 As String, ByVal dateClose As String, ByVal EmplClose As String)
Dim sql As String
dateClose = Replace(dateClose, "AM", "")
dateClose = Replace(dateClose, "PM", "")
sql = "UPDATE order SET description = '" & d1 & "', description2 = '" & _
d2 & "', Date_time_closed = '" & dateClose & "',Empl = '" & EmplClose & "' WHERE order_number = " & _
WO & ";"
cmdSql = New SqlCommand(sql, myConn)
myDA.UpdateCommand = cmdSql
myDA.Update(myDS, "order")
myConn.Close()
End Sub