This is classic vb string building. Your messagebox looks right because it concatenates the variables together.Does this work, add "'" (quote, single quote, quote) around your variables. Maybe it's + instead of &, been a long time since I VB'd anything.whereClause = "InspectionDate >= " & "'" & fromDate & "'" & " And InspectionDate <= " & "'" & toDate & "'"
whereClause = "InspectionDate >= " & "'" & fromDate & "'" & " And InspectionDate <= " & "'" & toDate & "'"
If I try to append to the where clause like this whereClause = "InspectionDate >= " & fromDate & " And InspectionDate <= " & toDate it doesn't work.
I think I got it. I set the variable to fromDate = frmTech1.FromDatePicker.Value.Date and fromDate is dimmed as Date. I perform the selection where clause as whereClause = "InspectionDate > " & fromDate & "" and it selected the values, all I need to do now is put multiple selections together. I previously just set the variable as value and nor as value.date.
I don't think that would work... I would think either you will get a type mismatch or the string returned by to the date picker will be whatever your locale is set which may or may not be wrong. There are two issues here, the conversion of the .net datetime type to string and the conversion from string to the sql server datetime (or date, datetime2) format in sql server. The .net tostring function is compiled when the .net code is compiled and executed on the local client at run time. The where clause is then passed as a string to a sql server database (local or on a server) which interprets and executes the sql where clause. In order to go from one the the other, you need a string in between to pass (whereclause.) The format of the string sql server needs will dictate what format the string you need to make from the .net datetime tostring function. Do you know the format the sql server needs to take in? Can you use a t-sql convert function in the where clause specifying the type of string (sql server's way of specifying the format)?
The only reason was to be in the same format as the date field. yyyy-MM-dd, hey, if I don't have to convert it to string and back to a date field great. I was using toDate = frmTech1.ToDatePicker.Value.ToString("yyyy-MM-dd"). So i shouldn't mess with format and leave it alone and sql server will format it correctly, is that what your saying? So it should be toDate = frmTech1.ToDatePicker.value and the where clause would be what exactly?
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.