Project assistance please

dave_retro82

New member
Joined
May 14, 2010
Messages
1
Programming Experience
Beginner
Hi, nice to be part of the community..
I'm fairly new to visual basic/asp.net, and I have been given a project with a short dead line, I'm getting nowhere and it's concerning me. I'd appreciate some assistance please if there is anyone kind enough out there.

I have a grid view on my web page. I also have an access database connected to it. The idea was to have only todays project showing in the gridview, by comparing today's date with the date entered in the project table ( from the add project page).

The trouble is I cannot directly compare the date because I can't put data from the database into a string and directly compare it with today's date, I don't know how. Even though it is wrong I have included some code below so you can see what I'm trying to do, thank you..


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'covert todays date to string
Dim dateTimeInfo As DateTime = DateTime.Now
'makes short date "d" i.e. 30/02/1984
Dim strMonth As String = dateTimeInfo.ToString("d")

'
'try to get date and compare today's date with table data
' Dim dtGetDate As New DataTable
' dtGetDate = DB.GetTable("Select Distinct Events.EventName FROM Event, Staff WHERE Events.EveID=Staff.EveID ")
'Dim str As String

'compare dates
' If (strMonth = dtGetDate) Then
'Dim dtProjects As New DataTable

'populate the datatable with the names of all projects from the database
' dtProjects = DB.GetTable("Select Event.Name, Staff.FirstName, Participant.FirstName FROM Participant, Staff, Event WHERE Event.EventDate=Participant.EventDate AND Event.EventDate=Staff.EventDate")

'Set the datasource for the lstProjects listbox to be the dtProject data table
' grvToday.DataSource = dtProjects

'set the listbox to display the Project Title on the screen
' lstToday.DataTextField = "FirstName"

'set the lstProjects listbox to use the ProjectNo column as the value
' lstToday.DataValueField = "StaffID"

'Bind the data to the lstProject listbox
' grvToday.DataBind()
' End If


End Sub

Edit/Delete Message:D
 
Wow. Way off. You're trying to compare two data types that won't equal each other. That's ok though. It's a learning experience...

VB.NET:
'covert todays date to string
Dim dateTimeInfo As DateTime = DateTime.Now

That part is fine. When you pull the Date from the table, load into a DateTime like so:

VB.NET:
Dim databaseDate As DateTime = DateTime.Parse(DB.GetTable(...))

The Use DateTime.Compare

VB.NET:
If DateTime.Compare(dateTimeInfo, databaseDate) = 0 Then
    ' The dates are the same!
End If

Do you understand what I'm trying to show you? Can you make this work?
 
Back
Top