my sql statement is returning null when when I compare date from access database and date entered in textbox in vb. seems to me that the two dates are of different format so null is returned from the select statement but how do I go about this. help please. my select is below:
("SELECT farmer_num as [FARMER'S NUMBER], " & _
"farmer_name as [FARMER'S NAME], farmer_village as [VILLAGE], farmer_phone as [PHONE NUMBER], reg_date as [REGISTRATION DATE], " & _
"farmer_centre as [CENTRE] FROM farmer where reg_date =" & TextBox.Text.ToString, cnn)`
First point, you shouldn’t be contencating in trusted user input into your SQL. It makes your code very vulnerable to SQL Injection, the most heavily exploited and easily prevented vulnerability out there.
You should be using parameterized queries instead.
That alone may solve your issue if you’re lucky. If you’re using parameterized queries, then the data type conversion happens almost “magically”. You don’t need to worry about it.
Here’s a link to an article specifically dealing with Access databases and .NET to help you along: http://www.mikesdotnetting.com/Article/26/Parameter-Queries-in-ASP.NET-with-MS-Access