Insert all values of a table into another table in SQL

后端 未结 9 1008
礼貌的吻别
礼貌的吻别 2020-11-29 16:56

I am trying to insert all values of one table into another. But the insert statement accepts values, but i would like it to accept a select * from the initial_Table. Is this

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 17:28

     Dim ofd As New OpenFileDialog
                    ofd.Filter = "*.mdb|*.MDB"
                    ofd.FilterIndex = (2)
                    ofd.FileName = "bd1.mdb"
                    ofd.Title = "SELECCIONE LA BASE DE DATOS ORIGEN (bd1.mdb)"
                    ofd.ShowDialog()
                    Dim conexion1 = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" + ofd.FileName
                    Dim conn As New OdbcConnection()
                    conn.ConnectionString = conexion1
                    conn.Open()
    
    
    
                'EN ESTE CODIGO SOLO SE AGREGAN LOS DATOS'
                Dim ofd2 As New OpenFileDialog
                ofd2.Filter = "*.mdb|*.MDB"
                ofd2.FilterIndex = (2)
                ofd2.FileName = "bd1.mdb"
                ofd2.Title = "SELECCIONE LA BASE DE DATOS DESTINO (bd1.mdb)"
                ofd2.ShowDialog()
                Dim conexion2 = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" + ofd2.FileName
                Dim conn2 As New OdbcConnection()
                conn2.ConnectionString = conexion2
                Dim cmd2 As New OdbcCommand
                Dim CADENA2 As String
    
                CADENA2 = "INSERT INTO EXISTENCIA IN '" + ofd2.FileName + "' SELECT * FROM EXISTENCIA IN '" + ofd.FileName + "'"
    
    
                cmd2.CommandText = CADENA2
                cmd2.Connection = conn2
                conn2.Open()
                Dim dA2 As New OdbcDataAdapter
                dA2.SelectCommand = cmd2
                Dim midataset2 As New DataSet
                dA2.Fill(midataset2, "EXISTENCIA")
    

提交回复
热议问题