0

Three one questions about releatie in MySQL with Visual Basic 2008.
How can i use Mydatapter1 over again and over agian (see code)?
So that i can fill three datasets
I want to fill three datasets with tree different tables and use them in my program

myCommand1.CommandText = "select * from table1"
myCommand1.Connection = myConn
myAdapter1.SelectCommand = myCommand1
myAdapter1.Fill(MyDataset1, "table1")
MyDataTable1 = MyDataset1.Tables("table1")
DataGridView1.DataSource = MyDataTable1

      
myCommand1.CommandText = "select * from table2"
myCommand1.Connection = myConn
myAdapter1.SelectCommand = myCommand1
myAdapter1.Fill(MyDataset2, "table2")
MyDataTable2 = MyDataset2.Tables("table2")
DataGridView2.DataSource = MyDataTable2

myCommand1.CommandText = "select * from table3"
myCommand1.Connection = myConn
myAdapter1.SelectCommand = myCommand1
myAdapter1.Fill(MyDataset3, "table3")
MyDataTable3 = MyDataset3.Tables("table3")
DataGridView3.DataSource = MyDataTable3
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by dre-logics
0
myCommand1.CommandText = "select * from table1"
myCommand1.Connection = myConn
myAdapter1.SelectCommand = myCommand1
myAdapter1.Fill(MyDataset1, "table1")
MyDataTable1 = MyDataset1.Tables("table1")
DataGridView1.DataSource = MyDataTable1

      
myCommand1.CommandText = "select * from table2"
myCommand1.Connection = myConn
myAdapter1.SelectCommand = myCommand1
myAdapter1.Fill(MyDataset1, "table2")
MyDataTable2 = MyDataset1.Tables("table2")
DataGridView2.DataSource = MyDataTable2

myCommand1.CommandText = "select * from table3"
myCommand1.Connection = myConn
myAdapter1.SelectCommand = myCommand1
myAdapter1.Fill(MyDataset1, "table3")
MyDataTable3 = MyDataset1.Tables("table3")
DataGridView3.DataSource = MyDataTable3
0

first globally create one data adapter that is

dim myadapter1 as DataAdapter 
''and whenever you want to use write in procedure
myAdpter1=new DataAdapter 
''after your code for first DataGridView
''at the end of 1 DataGridView write
myAdpter1.Close
myAdpter1=nothing 
''then further write
myAdpter1=new DataAdapter 
'' end so on.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.