HI
I am trying to write data to an access table from vb.net. The code all seems to run fine but when i check the db no new data has been entered!
the code i have got is:
I wondered if anyone had ideas what i was doing wrongCode:Dim itemcount As Integer Dim MyCn As OleDbConnection Dim sql As String 'Dim Value As String Dim Command As OleDbCommand Try con.Open() MyCn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\BillAnalyst\ReferenceData.mdb") For Each ListView In lstErrors.Items itemcount = itemcount + 1 sql = "INSERT INTO CAllRates (CallRates.Destination) VALUE (" & ListView & ")" Command = New OleDbCommand(sql, MyCn) Next Catch ex As Exception MessageBox.Show(ex.Message & " - " & ex.Source) con.Close() End Try lblcount.Text = itemcount Dim itemcount As Integer Dim MyCn As OleDbConnection Dim sql As String 'Dim Value As String Dim Command As OleDbCommand Try con.Open() MyCn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\BillAnalyst\ReferenceData.mdb") For Each ListView In lstErrors.Items itemcount = itemcount + 1 sql = "INSERT INTO CAllRates (CallRates.Destination) VALUE (" & ListView & ")" Command = New OleDbCommand(sql, MyCn) Next Catch ex As Exception MessageBox.Show(ex.Message & " - " & ex.Source) con.Close() End Try lblcount.Text = itemcount
many thanks




Reply With Quote