Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
SQL
da = New SqlDataAdapter("Select token_no from billentry where billdate= #" & Today & "#", myconn)
Posted

da = New SqlDataAdapter("Select token_no from billentry where billdate='" + Today + "'", myconn)
 
Share this answer
 
use parameters like below

VB
da = New SqlDataAdapter("Select token_no from billentry where billdate= @billdate", myconn)
adapter.SelectCommand.Parameters.Add("@billdate", _
          SqlDbType.DateTime, 0,Today)



read Give me parameterized SQL, or give me death[^]
 
Share this answer
 
v3
Try replacing # with '
# is a date delimiter for Visual Basic not SQL.

Better yet, do it the way a professional programmer would.
Use the SQLParameter Class to store the value of Today in Date Type format and construct your SQL statement to utilize the parameter value in the SQLParameter object. Doing so prevents those intent on doing evil things from using the SQL Injection technique to erase or alter your database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900