Results 1 to 2 of 2

Thread: Copy from one table to another

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    29

    Copy from one table to another

    A newbie question... I'm re-coding a program I wrote in MS Access using VB .Net. I'm trying to copy the content from one table (partdata) into another (temp). Both tables have identical number of fields and field names (part_number & part_price).

    In Access, I used a "docmd.runsql" to execute a SQL INSERT statement to copy the table. How can I do the same in VB .Net?

  2. #2
    Addicted Member
    Join Date
    Jul 2000
    Location
    didn't decide yet
    Posts
    222
    Code:
          Dim cnNew As New OleDb.OleDbConnection(cntProvider & "Data Source=" & Application.StartupPath & "\db.mdb")
           cnNew.Open()
           Dim cmd As OleDbCommand
    
            cmd = New OleDbCommand("INSERT INTO TABLE1 ( FirstN, LastN, Address, Phone, Dimoi, Job )
    SELECT TABLE2.FirstN, TABLE2.LastN, TABLE2.Address, TABLE2.Phone, TABLE2.Dimoi, TABLE2.Job
    FROM TABLE2;
    ", cnNew)
            Try
                cmd.ExecuteNonQuery()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            cnNew.Close()
    Come and get our ISDN CallerID http://www.3wm.biz

Posting Permissions

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



Click Here to Expand Forum to Full Width