I want to show a treeview control in visual studio 2005 (or 2008) which shows the date a task was done and when it is clicked on it also shows all the task IDs done on that date. The database is a MySQL database and stores datetime values so I've had to convert these to date values. The values for TaskID and TimePosted (the dateTime field) are in the same table. The problem is I can get the date to be listed, but I cant get all the tasks done on that date to be listed as child nodes. The code is below. Can anyone help?
Imports System.Data.Odbc
Imports System.Data.SqlClient
Imports System.Data
Partial Class tbbDocumentExpl
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConn As String = "DATABASE=blabla;DESCRIPTI
ON=blabla;
DSN=blabla
;OPTION=0;
PORT=0;SER
VER=xxxxxx
x;UID=xxx"
Dim objConn As New OdbcConnection(strConn)
Dim objDS As New DataSet
Dim s As String = "'sebastiz'"
'Dim s As String = "'" & System.Web.HttpContext.Cur
rent.Sessi
on("seb") & "'"
Dim daTask As New OdbcDataAdapter("SELECT TaskID, SecretaryID, date_format(TimePosted,'%W
%M %Y')as Newdate FROM Task GROUP BY Newdate", objConn)
Dim daUser As New OdbcDataAdapter("SELECT UserName, UserID FROM User WHERE UserName=" & s, objConn)
Dim daSec As New OdbcDataAdapter("SELECT SecretaryID, UserID FROM Secretary", objConn)
daTask.Fill(objDS, "dtTask")
daUser.Fill(objDS, "dtUser")
daSec.Fill(objDS, "dtSec")
objConn.Close()
objDS.Relations.Add("TaskT
oSec", _
objDS.Tables("dtSec").Colu
mns("Secre
taryID"), objDS.Tables("dtTask").Col
umns("Secr
etaryID"),
False)
objDS.Relations.Add("SecTo
User", _
objDS.Tables("dtUser").Col
umns("User
ID"), _
objDS.Tables("dtSec").Colu
mns("UserI
D"), False)
Dim nodeUser, nodeTask As TreeNode
Dim rowUser, rowTask, rowsecretary, rowdate As DataRow
Try
For Each rowdate In objDS.Tables("dtTask").Row
s
nodeUser = New TreeNode
nodeUser.Text = rowdate("Newdate")
TreeView1.Nodes.Add(nodeUs
er)
For Each rowdate("Newdate") In objDS.Tables("dtTask").Row
s
nodeTask = New TreeNode
nodeTask.Text = rowTask("TaskID")
nodeUser.ChildNodes.Add(no
deTask)
Next
Next
Catch ex As Exception
End Try
Try
Dim dr As OdbcDataReader
Dim str As String = TreeView1.SelectedNode.Tex
t
'Dim daTask As New OdbcDataAdapter("SELECT TaskID,Transcript SecretaryID FROM Task WHERE TaskID='" & s & "'", objConn2)
'daTask.Fill(objDS, "dtTask")
Dim comm As New OdbcCommand("SELECT Transcript, TimePosted FROM Task WHERE TaskID='" & str & "'", objConn)
objConn.Open()
dr = comm.ExecuteReader()
dr.Read()
TextBox1.Text = dr("Transcript").ToString
objConn.Close()
Catch ex As Exception
End Try
objDS.Dispose()
daTask.Dispose()
daUser.Dispose()
daSec.Dispose()
objConn.Dispose()
End Sub
End Class