G
GADOI
Hello:
Using VS2008 .net 3.5
I have a data table (MyDataTable) that has records i want to insert into an
access accdb table (AllAgents).
I am using the following function
Public Function OverWriteAgents(ByVal MydataTable As DataTable) As
String
Dim AccessConnection As New
System.Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Ace.OLEDB.12.0;Persist
Security Info = False; Data Source=" + MdbPath)
Try
AccessConnection.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("INSERT
INTO AllAgents(LICNUM,NAME,EXPDATE) SELECT LICNUM,NAME,EXPDATE from
[MydataTable]", AccessConnection)
AccessCommand.ExecuteNonQuery()
AccessConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
AccessConnection.Close()
End Try
End Function
but no records are updated because the inset statement contains the name of
the table but does not reference it.
I just dont know how to do this.
Help
Thanks
T
Using VS2008 .net 3.5
I have a data table (MyDataTable) that has records i want to insert into an
access accdb table (AllAgents).
I am using the following function
Public Function OverWriteAgents(ByVal MydataTable As DataTable) As
String
Dim AccessConnection As New
System.Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Ace.OLEDB.12.0;Persist
Security Info = False; Data Source=" + MdbPath)
Try
AccessConnection.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("INSERT
INTO AllAgents(LICNUM,NAME,EXPDATE) SELECT LICNUM,NAME,EXPDATE from
[MydataTable]", AccessConnection)
AccessCommand.ExecuteNonQuery()
AccessConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
AccessConnection.Close()
End Try
End Function
but no records are updated because the inset statement contains the name of
the table but does not reference it.
I just dont know how to do this.
Help
Thanks
T