Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27418

VS 2010 multiple oledbadaptor

$
0
0
Good Evening,
im new and wondering if anyone was able to shed some light.

i have a form that contains one textbox and three datagrids.

what im trying to do is search the textbox field to an access database.

Code:

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 OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=..\Data2.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()
        Dim myDataSet2 As DataSet = New DataSet()
        myDA.Fill(myDataSet, "MFocus")
        DataGridView2.DataSource = myDataSet.Tables("MFocus").DefaultView
       
        myDA2.Fill(myDataSet2, "Mtarget")
        DataGridView3.DataSource = myDataSet2.Tables("Mtarget").DefaultView
    End Sub
End Class

the myda2 gives the following error
Record(s) cannot be read; no read permission on 'Mtarget'.


anyone able to help

thanks,

Viewing all articles
Browse latest Browse all 27418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>