cpopham Posted September 3, 2004 Posted September 3, 2004 I have changed my data typeto text in my Access database, but I am still not getting any results. This is my code: Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged Dim strSelected As String = Calendar1.SelectedDate.Date.ToShortDateString Dim STRs As Date = CDate(strSelected) myDA = New OleDbDataAdapter("SELECT * " & _ "FROM EventsTable " & _ "WHERE EventDate= '" & strSelected & "'", myConnection) dsSelDate = New DataSet myDA.Fill(dsSelDate) If dsSelDate.Tables(0).Rows.Count = 0 Then DataGrid1.Visible = False Else DataGrid1.Visible = True DataGrid1.DataSource = dsSelDate DataGrid1.DataBind() End If End Sub I am choosing a date that has information and when I run the query in my database with the selected date, it works fine, but I can not get it to work in code. Any ideas? Chester Quote ____________________________________________ http://www.pophamcafe.com I am starting a developers section, more tutorials than anything.
*Experts* Nerseus Posted September 3, 2004 *Experts* Posted September 3, 2004 I believe you must use the number/pound sign to surround a Date in Access: SELECT * FROM Table1 WHERE DateColumn = #12/31/1999# In SQL Server you use single quotes: SELECT * FROM Table1 WHERE DateColumn = '12/31/1999' There's probably also some preferred format that Access will want - maybe "month/day/year" vs "year/month/day" etc. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
cpopham Posted September 3, 2004 Author Posted September 3, 2004 I got it to work. I put my SQL statement in a string variable and it works fine now :) My only problem would be if I was working with a database that I could not change the data type to string and it stayed as a date. Chester Quote ____________________________________________ http://www.pophamcafe.com I am starting a developers section, more tutorials than anything.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.