Updating A Datagrid
Posted on 2006-06-16
I am trying to update a Dataset from editted data from a datagrid. If there is no change of the data when the update is performed there is no problem, However if there is a change in the data within the datagrid the code fails. Could some one tell what is wrong with this code?
Sub UpdateDataDS(ByRef sSlctCust As String, ByRef sSlctRprt As String)
Dim strSQL As String
Dim daData As SqlClient.SqlDataAdapter
strSQL = "Select CUSTNO, PROJECT, LAB_NO, CYLINDER, [LOAD], POUNDS, REQUIRED," & _
"AGE, SLUMP, AIR, AMBIENT, CONCRETE, DATE_TEST from LLCOND" & sLocation & " where CUSTNO = " & _
"'" & sSlctCust & "'" & " And LAB_NO = " & "'" & sSlctRprt & "'" & " Order by CYLINDER Asc"
daData = New SqlClient.SqlDataAdapter(strSQL, cn)
daData.Fill(dsData, "LLCOND" & sLocation)
daData.UpdateCommand = New SqlClient.SqlCommand("UPDATE LLCOND" & sLocation & " where CUSTNO = " & sSlctCust & " And LAB_NO = " & sSlctRprt, cn)
'WHEN AN UPDATE OCCURS THIS LINE CAUSES AN ERROR ONLY IF THERE WAS A CHANGE IN DATA
daData.Update(dsData, "LLCOND" & sLocation)
Catch ex As Exception