MySQL Relations Help

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.

 
How can that possibly be the case? The line you say you have put the breakpoint on is not even inside the exception handler that displays that MessageBox according to your code.
 
issue

Well I knew the code was ok, because I was using in a previous version of the application. The only difference was that before I was using Access, and now I'm using MySQL. I guess when I was writing the code and set the tables, columns and relations in the wrong order.

When I type the data here I edited, and after you post your first message I decide to rewrite all that again and notice that I mess up creating the relations. The code was ok (in the syntax) but not logically.
 
Back
Top