Results 1 to 1 of 1
  1. #1
    Join Date
    Feb 2005

    Post Unanswered: Using Select Statement from 1 database to insert into another database using VB .NET


    I am currently writing a VB .NET application where I am trying to open 1 database, create a select statement and then post the results into another database file using Microsoft Access database 2002.

    The code seems to stop executing at the statement "cmdJetDB.ExecuteNonQuery()"

    I am using the following code:

    Dim conn1 As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data source=C:\Sample.mdb")

    Dim conn2 As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data source=C:\db2.mdb")
    Dim mySelectQuery As String
    mySelectQuery = "SELECT Sample.LANE_ADDR, Sample.LANE_DT, Sample.LANE_TM, Sample.LANE_SPEED FROM (Sample) WHERE ((Sample.LANE_ADDR) = '164.909' OR (Sample.LANE_ADDR) = '164.909' AND Sample.LANE_DT BETWEEN #4/4/2003# AND #4/5/2003#)"
    Dim cmdJetDB As New OleDbCommand(mySelectQuery, conn1)

    Dim cmdInsert As String
    cmdInsert = "Insert INTO Table1 (Sample.LANE_ADDR, Sample.LANE_TM,Sample.LANE_SPEED) VALUES ('164.909', '00:12:30' , '30' )"
    Dim cmdJetDB2 As New OleDbCommand(cmdInsert, conn2)


    Question: What is it that I am not doing. I opened both connections, stated my two SQL statements, yet it is still not working. I really need to get this application working. I have spent the past 2 days working on this problem. Please Help.........
    Last edited by mveliz; 02-18-05 at 12:34. Reason: I left some code out

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts