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;DESCRIPTION=blabla;DSN=blabla;OPTION=0;PORT=0;SERVER=xxxxxxx;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.Current.Session("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("TaskToSec", _
objDS.Tables("dtSec").Columns("SecretaryID"), objDS.Tables("dtTask").Columns("SecretaryID"), False)
objDS.Relations.Add("SecToUser", _
objDS.Tables("dtUser").Columns("UserID"), _
objDS.Tables("dtSec").Columns("UserID"), False)
Dim nodeUser, nodeTask As TreeNode
Dim rowUser, rowTask, rowsecretary, rowdate As DataRow
Try
For Each rowdate In objDS.Tables("dtTask").Rows
nodeUser = New TreeNode
nodeUser.Text = rowdate("Newdate")
TreeView1.Nodes.Add(nodeUser)
For Each rowdate("Newdate") In objDS.Tables("dtTask").Rows
nodeTask = New TreeNode
nodeTask.Text = rowTask("TaskID")
nodeUser.ChildNodes.Add(nodeTask)
Next
Next
Catch ex As Exception
End Try
Try
Dim dr As OdbcDataReader
Dim str As String = TreeView1.SelectedNode.Text
'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
by: AUmidhPosted on 2008-01-21 at 02:46:16ID: 20704949
What is your Tables Structure... ? you are getting date and task id's from one table.... please describe in a paragraph..