Tuesday, December 7, 2010

ADO.NET hierarchical data from database

i dont know why but i am unable to draw parentchild relations with this code in IE

Public Function ReceiveDataSet(ByVal CategoryID As String) As DataSet
'Get the data from database and put it in the DataSet
Dim nwindConn As OleDbConnection = New OleDbConnection("Provider=MSDataShape;Data Provider=SQLOLEDB;" & _
"Data Source=.;Integrated Security=SSPI;Initial Catalog=northwind; user id=sa; password=123")
Dim custDA As OleDbDataAdapter = New OleDbDataAdapter("SHAPE {SELECT CategoryID, CategoryName FROM Categories where categoryID=" & CategoryID & "} " & _
" APPEND ({SELECT * FROM Products} AS Products " & _
" RELATE CategoryID TO CategoryID)", nwindConn)
Dim custDS As DataSet = New DataSet
custDA.Fill(custDS, "Categories")
Return custDS
Catch ex As Exception
End Try

No comments:

Post a Comment