By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,928 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,928 IT Pros & Developers. It's quick & easy.

Need Help Please

P: n/a
here is my code for a btn click event. i want to insert fields from
one access db to another.
look for ->>>>>>> below. can some help me with this syntax? am i
opening the db's correctly? Thanks in advanced.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
'opening connection to db with file dialog
Dim connDB As Odbc.OdbcConnection = New Odbc.OdbcConnection
Try
MsgBox("Select 'Ilsatemp.mdb' file.")
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName

connDB.ConnectionString = "Driver={Microsoft Access Driver
(*.mdb)};Dbq=" & Me.TextBox1.Text & ";"

Dim dbAdapter As Odbc.OdbcDataAdapter = New
Odbc.OdbcDataAdapter("select * from PDAReorder_Pending", connDB)

Dim dbTable As New DataTable
dbAdapter.Fill(dbTable)
Me.DataGridView1.DataSource = dbTable

Dim intCounter As Integer
intCounter = DataGridView1.Rows.Count
Label2.Text = intCounter - 1
' opening another database to transfer fields from temp to
ilsa
Dim connIlsaDB As Odbc.OdbcConnection = New
Odbc.OdbcConnection

Try
MsgBox("Select the 'Ilsa.mdb' file to open.")
OpenFileDialog1.ShowDialog()
Label6.Visible = True
Label6.Text = "Database: " & OpenFileDialog1.FileName &
" is open"
connIlsaDB.ConnectionString = "Driver={Microsoft Access
Driver (*.mdb)};Dbq=" & Me.TextBox1.Text & ";"

'Below i'm copy the data from the temp table to the
ilsa table
->>>>>>> Dim dbILSA1Adapter As Odbc.OdbcDataAdapter =
New Odbc.OdbcDataAdapter("Insert into POrdData (VEND_PART_NUM, PLU_NUM,
QTY, EST_COST) Values (VendorPart, PLU_NUM, Qty, EST_COST) from
PDAReorder_Pending", connIlsaDB)

'Ending the Copy table functions
Catch ex As Exception
MsgBox("Error: " & ex.Message)

Finally
If connIlsaDB.State <> ConnectionState.Closed Then
connIlsaDB.Close()
End If
End Try

Catch ex As Exception
MsgBox("Error: " & ex.Message)

Finally
If connDB.State <> ConnectionState.Closed Then
connDB.Close()
End If
End Try
End Sub

May 23 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.