hey everybody,
i am new to vb.net environment pls help me to sort out my problem. let me explain it.
in my project i need to clone/copy the content of the two fields from one table to another table in same database.i have tried my level best but got the error in coding. can anuyone solve it pls. its vry urgent.

        Dim tblProducts As DataTable
        Dim tblProductsCopy As DataTable
        Dim tblProductsCount, tblProductsCopyCount, i As Integer
        conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Module2.accdb")
        Dim da As OleDbDataAdapter 'Create the DataAdapter.
        da = New OleDbDataAdapter("Select Itemname,ItemCode from sub", conn)
        Dim ds As DataSet = New DataSet("Products")

        da.Fill(ds, "products")
        ds.Tables.Add(tblProducts)

        tblProductsCount = tblProducts.Rows.Count


        tblProductsCopy = tblProducts.Clone()


        tblProductsCopy.ImportRow(tblProducts)

        tblProductsCopyCount = tblProductsCopy.Rows.Count

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

Recommended Answers

All 2 Replies

Something like this would do the trick:

"INSERT INTO destinationTable(Itemname,Itemcode)" & _
  "SELECT sourceTable.ItemName, sourceTable.ItemCode " & _
   "FROM sourcetable WHERE sourcetable.Column=Value"

hey thanks...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.