jlcarbwood
Member
- Joined
- Nov 27, 2005
- Messages
- 10
- Location
- Lawrenceburg, Indiana, United States
- Programming Experience
- Beginner
Ok, here is my problem
I'm able to connect to MySQL DB with no problem, I fill the Dataset and preview my data in a DataGrid. I love data from 2tables (table1, table2)
Now I'm trying to load some nodes in a treeview, I had done this with access database with no problem creating some relations.
Now for some reason is not working on MySQL DB, is not giving me any error, but is not loadin the tree, een that the datagrid is showing the data bein load.
Here is the code:
Try
Dim connection, query, query2 AsString
Dim conn AsNew MySQLConnection(connection)
Dim MyConString As MySQLConnectionString
MyConString = New MySQLConnectionString("mysite.com", "my_db", "myuser", "mypass")
query = "SELECT * FROM tbl1 "
query2 = "SELECT * FROM tbl2"
'(MyConString)
conn = New MySQLDriverCS.MySQLConnection(MyConString.AsString)
conn.Open()
da1.SelectCommand = New MySQLCommand(query, conn)
da1.Fill(dataSet, "dt1")
'
da2.SelectCommand = New MySQLCommand(query2, conn)
da2.Fill(dataSet, "dt2")
'
conn.Close()
Catch ex As Exception
MsgBox("Failed to Connect to Network")
EndTry
Dim node1, node2, node3 As TreeNode
Dim row1, row2, row3 As DataRow
node1 = New TreeNode
node1.Text = "MyNode"
TreeView1.Nodes.Add(node1)
Dim dc1 AsNew DataRelation("MyRelation", _
dataSet.Tables("dt1").Columns("MyColumn2"), _
dataSet.Tables("dt2").Columns("MyColumn2"))
dataSet.Relations.Add(dc1)
For Each row1 In dataSet.Tables("dt1").Rows
node2 = New TreeNode
node2.Text = row1("MyColumn1")
node1.Nodes.Add(node2)
For Each row2 In row1.GetChildRows("MyRelation")
node3 = New TreeNode
node3.Text = row2("MyColumn3")
node2.Nodes.Add(node3)
Next row2
Next row1
I made a break point on:
dataSet.Relations.Add(dc1)
When it gets to this point it stop, at this point the msgbox pop
MsgBox("Failed to Connect to Network")
I know the connection was made, so i have no idea how to relsolve this. The same code works on a local db with no problem.
Any help will be gladly accepted.
I'm able to connect to MySQL DB with no problem, I fill the Dataset and preview my data in a DataGrid. I love data from 2tables (table1, table2)
Now I'm trying to load some nodes in a treeview, I had done this with access database with no problem creating some relations.
Now for some reason is not working on MySQL DB, is not giving me any error, but is not loadin the tree, een that the datagrid is showing the data bein load.
Here is the code:
Try
Dim connection, query, query2 AsString
Dim conn AsNew MySQLConnection(connection)
Dim MyConString As MySQLConnectionString
MyConString = New MySQLConnectionString("mysite.com", "my_db", "myuser", "mypass")
query = "SELECT * FROM tbl1 "
query2 = "SELECT * FROM tbl2"
'(MyConString)
conn = New MySQLDriverCS.MySQLConnection(MyConString.AsString)
conn.Open()
da1.SelectCommand = New MySQLCommand(query, conn)
da1.Fill(dataSet, "dt1")
'
da2.SelectCommand = New MySQLCommand(query2, conn)
da2.Fill(dataSet, "dt2")
'
conn.Close()
Catch ex As Exception
MsgBox("Failed to Connect to Network")
EndTry
Dim node1, node2, node3 As TreeNode
Dim row1, row2, row3 As DataRow
node1 = New TreeNode
node1.Text = "MyNode"
TreeView1.Nodes.Add(node1)
Dim dc1 AsNew DataRelation("MyRelation", _
dataSet.Tables("dt1").Columns("MyColumn2"), _
dataSet.Tables("dt2").Columns("MyColumn2"))
dataSet.Relations.Add(dc1)
For Each row1 In dataSet.Tables("dt1").Rows
node2 = New TreeNode
node2.Text = row1("MyColumn1")
node1.Nodes.Add(node2)
For Each row2 In row1.GetChildRows("MyRelation")
node3 = New TreeNode
node3.Text = row2("MyColumn3")
node2.Nodes.Add(node3)
Next row2
Next row1
I made a break point on:
dataSet.Relations.Add(dc1)
When it gets to this point it stop, at this point the msgbox pop
MsgBox("Failed to Connect to Network")
I know the connection was made, so i have no idea how to relsolve this. The same code works on a local db with no problem.
Any help will be gladly accepted.