hello, im new to vb.net programming and im trying to connect to an access database.
the following is my code, it works for the first connection,but if i want to connect to a 2nd and 3rd it stops and says i dont have permission anyone able to share some insight.
thanks for your time.
the following is my code, it works for the first connection,but if i want to connect to a 2nd and 3rd it stops and says i dont have permission anyone able to share some insight.
thanks for your time.
VB.NET:
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Dim SearchJob As String = TextBox1.Text
Dim SearchJob2 As String = TextBox1.Text
'From the textbox this searches the mfocus,mtarget,mbs table
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=..\Data.mdb")
'Dim con2 As OleDbConnection = New OleDbConnection2("Provider=Microsoft.jet.oledb.4.0;data source=..\Data.mdb")
' Use wildcard'
Dim cmd As OleDbCommand = New OleDbCommand("SELECT [Fieldname],tablename,datatype1 FROM [Mfocus] WHERE [Fieldname] Like '%" & SearchJob & "%' ", con)
'Dim cmd2 As OleDbCommand = New OleDbCommand("SELECT [Field name],[database table],[fieldtype],[Field length] FROM [Mtarget] WHERE [Field name] Like '%" & SearchJob2 & "%' ", con2)
con.Open()
con2.Open()
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim myDA2 As OleDbDataAdapter = New OleDbDataAdapter(cmd2)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "MFocus")
DataGridView2.DataSource = myDataSet.Tables("MFocus").DefaultView
Dim myDataSet2 As DataSet = New DataSet()
myDA2.Fill(myDataSet2, "Mtarget")
DataGridView3.DataSource = myDataSet2.Tables("Mtargets").DefaultView
End Sub