Insert into existing table repeatedly

  • Hi,

    I am using the following code in vb.net to import data from a CSV file (a simple text file).

    Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyDB.mdb")

    Dim cmd As New OleDbCommand("SELECT * INTO tblNewOne FROM [Text;Database=C:\;Hdr=No].[Myfile.txt]", conn)

    conn.Open()

    Try

    cmd.ExecuteNonQuery()

    Catch ex As Exception

    MsgBox(ex.ToString)

    End Try

    conn.Close()

    When executed the first time, the contents from the file are imported into the table. After about 5 min, the contents of the Myfile.txt is changed (the data comes from another source for the text file). I want to now add the contents from the text file to the same table using the above code, but the error 'table already exists' appear and the operation fails. Is there a way to overcome this error and import the new values from the file.

    thanks for the answers.

    Senthil

  • Instead of Using Select Into Use Insert Into.

    Select Into create a table, while insert into inserts data into an existing table. BOL has a good reference describing the differences.

    To help us help you read this[/url]For better help with performance problems please read this[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply