HI

I am trying to write data to an access table from vb.net. The code all seems to run fine but no data is being sent to the db though!

the code i have got is

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

I wondered if anyone had ideas what i was doind wrong

many thanks

you are trying to send back data from listview, but you didnt declare from which part the data should move back i mean

there should be

listview.SelectedItem.To String()

you are trying to send back data from listview, but you didnt declare from which part the data should move back i mean

there should be

listview.SelectedItem.To String()

Hi, many thanks for responding.

I dont really know where i should be putting the amendment
listview.SelectedItem.To String()

I wondered if you could let me know

kind regards

sql = "INSERT INTO CAllRates (CallRates.Destination) VALUE (" & ListView.SelectedItem.ToString() & ")"

hi

have found the resolve for the first bit - added:

Command.ExecuteNonQuery()

which got it to execute, but now i get the error :

could not find file: c:\documents and settings\Simon\My Documents\Visual Studio 2008\Projects\BillAnalyst\BillAnalyst\bin\Debug\Callrates.mdb

but the connection string points to:

C:\BillAnalyst\ReferenceData.mdb


cant understand why the path is different and it cant see it where im pointing it to

UPDATE:

The new error was caused by an error in the SQL:

change it to INSERT INTO CallRates (Destination) VALUES ('" & ListView & "') and it all works fine

many thanks for everyones help

regards

Hi friends......
I need full vb.net code of inserting values to the ms access database.. Can anybody help me???????

This question has already been answered. Start a new discussion instead.