bokaraton
02-26-2004, 11:03 AM
When I click update, I am getting this error message:
"Update unable to find TableMapping ['Table'] or TableData 'Table'
Does anyone know how to resolve this problem?
MKoslof
02-26-2004, 05:34 PM
Can you post the code you are using..it will be easier to find the problem and we can get a full perspective of what you are trying to do.
bokaraton
03-01-2004, 03:33 PM
Can you post the code you are using..it will be easier to find the problem and we can get a full perspective of what you are trying to do.
Here's the code...I wrote the rUpdate Function because the Me.UpdateDataSet(generated by DataFormWizard) does not work when I filter and load the dataset with filtered record.
I think my rUpdate function maybe clearing out the tablemapping generated by the wizard...thats my guess. Anyway, Please help...thanks.
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
'UPDATE
Try
'Attempt to update the datasource.
If Global.findFlag = False Then
Me.UpdateDataSet()
Else
Call rUpdate()
Me.Refresh()
End If
sbpStatus.Text = "Update Completed Successfully"
Catch eUpdate As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objVrData_PositionChanged()
End Sub
***UPDATE FUNCTION
Private Function rUpdate() As Boolean
Dim strConnectionString As String
Dim strSQL As String
Dim blnR As Boolean
Dim strLoanType As String
Dim Key As String
Dim cnVrData As System.Data.OleDb.OleDbConnection
Dim cmUpdate As System.Data.OleDb.OleDbCommand
Try
blnR = True
If blnR Then
strLoanType = Nothing
Key = editItemNumber.Text
strSQL = "Update Itmmas Set "
'strSQL = strSQL & "ItemNumber = '" & CStr(editItemNumber.Text) & "', "
strSQL = strSQL & "ItemDescription = '" & CStr(editItemDescription.Text) & "', "
strSQL = strSQL & "ProductCategory = '" & CStr(editProductCategory.Text) & "' "
strSQL = strSQL & "WHERE (ItemNumber = '" & Key & "');"
If Not (cmUpdate Is Nothing) Then
cmUpdate.Dispose()
cmUpdate = Nothing
End If
'OPEN CONNECTION
strConnectionString = Global.SET_ConnectionString
If Not Utility.OpenConnection(cnVrData, strConnectionString) Then
Utility.Terminate()
End If
'WRITE TO DATABASE
cmUpdate = New System.Data.OleDb.OleDbCommand(strSQL, cnVrData)
cmUpdate.CommandText = strSQL
cmUpdate.ExecuteNonQuery()
End If
Return blnR
Catch ex As Exception
MsgBox(Err.Number & " " & Err.Description & Err.Source, MsgBoxStyle.Information, "Error")
Finally
If Not (cmUpdate Is Nothing) Then
cmUpdate.Dispose()
cmUpdate = Nothing
End If
If Not (cnVrData Is Nothing) Then
If cnVrData.State = ConnectionState.Open Then
cnVrData.Close()
End If
cnVrData = Nothing
End If
End Try
End Function