I need help updating a record using ADO.Net. I get the following error whenever I attempt to update:
An unhandled exception of type 'System.InvalidOperationException'
Occurred in System.Data.Common.dll
Additional information: Update unable to find TableMapping['Table'] or
DataTable 'Table'
Here is the code I am using:
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlDataAdapter
Imports System.Data.DataSet
Public Function SaveUpdate(ByVal strWO As String, ByVal strProcess As String, _
ByVal intPTI As Integer, ByVal intQty As Integer) As Integer
Dim cn3 As New SqlConnection
'Initialize Objects
cn3 = New SqlConnection("Data Source = DAM3;" & _
"Initial Catalog=Scheduling;UserID=User1; PassWord=IT100;")
Dim strSQL As String
Dim cmdUpdate As New SqlCommand
cmdUpdate = New SqlCommand
'Set Up Command
strSQL = "UPDATE tblWorkOrderDtl " _
& "SET ActualQty = '" & intQty & "'," _
& "PTI = '" & intPTI & "' " _
& "WHERE WorkOrderNo = '" & strWO & "' " _
& "AND ProcessStep = '" & strProcess & "'"
cmdUpdate.CommandText = strSQL
cmdUpdate.CommandType = CommandType.Text
cmdUpdate.Connection = cn3
'Dim cn As New SqlConnection
Dim dResults As DataSet
dResults = New DataSet
Dim adPerson As SqlDataAdapter
adPerson = New SqlDataAdapter
adPerson.UpdateCommand = cmdUpdate
cn3.Open()
adPerson.Update(dResults, "tblWorkOrderDtl")
cn3.Close()
End Function
Am I not setting the right references. Please help.
Thank you,
RR
An unhandled exception of type 'System.InvalidOperationException'
Occurred in System.Data.Common.dll
Additional information: Update unable to find TableMapping['Table'] or
DataTable 'Table'
Here is the code I am using:
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlDataAdapter
Imports System.Data.DataSet
Public Function SaveUpdate(ByVal strWO As String, ByVal strProcess As String, _
ByVal intPTI As Integer, ByVal intQty As Integer) As Integer
Dim cn3 As New SqlConnection
'Initialize Objects
cn3 = New SqlConnection("Data Source = DAM3;" & _
"Initial Catalog=Scheduling;UserID=User1; PassWord=IT100;")
Dim strSQL As String
Dim cmdUpdate As New SqlCommand
cmdUpdate = New SqlCommand
'Set Up Command
strSQL = "UPDATE tblWorkOrderDtl " _
& "SET ActualQty = '" & intQty & "'," _
& "PTI = '" & intPTI & "' " _
& "WHERE WorkOrderNo = '" & strWO & "' " _
& "AND ProcessStep = '" & strProcess & "'"
cmdUpdate.CommandText = strSQL
cmdUpdate.CommandType = CommandType.Text
cmdUpdate.Connection = cn3
'Dim cn As New SqlConnection
Dim dResults As DataSet
dResults = New DataSet
Dim adPerson As SqlDataAdapter
adPerson = New SqlDataAdapter
adPerson.UpdateCommand = cmdUpdate
cn3.Open()
adPerson.Update(dResults, "tblWorkOrderDtl")
cn3.Close()
End Function
Am I not setting the right references. Please help.
Thank you,
RR