I can’t figure this out?
I am trying to use a MonthcCalendar to permit my user to pick various dates after which it have the particular database go back information based on those schedules.The appointments should get data from a field or perhaps fields reported by all days selected.While i run this query like this “MonthCalendar1.SelectionStart” in addition to choose one simple date this program works okay, when I aim to chose various dates (as below) this gives me the problem this error “Syntax miscalculation in particular date in query expression”
This is my code utilizing a MonthCalendar plus DataGridView
Individual Sub MonthCalendar1_SelectedRange(ByVal sender Because System.Object, ByVal electronic As System.Windows.Styles.DateRangeEventArgs) Addresses MonthCalendar1.DateSelected
Dim Datev Because String
Datev = MonthCalendar1.SelectionStart + ” — ” + MonthCalendar1.SelectionEnd
Dim con Because OleDbConnection = New OleDbConnection
Dim cmd Because OleDbCommand = Fresh OleDbCommand
disadvantage.ConnectionString = “Provider=Microsoft.Plane.OLEDB.FOUR.0; Facts Source=C:\Users\Jay\Desktop\Single Friends and family Tech Verify.mdb” ‘setting connectionString
cmd.CommandText = “Select Deal with from (TechCheckData) Wherever (Pre-Assessment = (#” & Datev & “#))” ‘setting sql embed statement along with value
cmd.Link = con
disadvantage.Open()
Dim myconnection Because New OleDbConnection(con.ConnectionString)
Dim mycommand Because New OleDbCommand(cmd.CommandText, myconnection)
Dim myadapter Because New OleDbDataAdapter
Dim mydataset Because New DataSet
myadapter.SelectCommand = mycommand
myadapter.Fill(mydataset, “TechCHeckData”)
DataGridView1.DataSource = mydataset.Tables(“TechCheckData”)
cmd.ExecuteNonQuery()
cmd.Dispose()
disadvantage.Close()
disadvantage.Dispose()
End Sub
Your WHERE clause should be something along the order of
Where Pre-Assessment AMONG #” & MonthCalendar1.SelectionStart & “# AND #” & MonthCalendar1.SelectionEnd & “#”.
Leave a Reply
You must be logged in to post a comment.