Error in oledb query

Ronak

Member
Joined
Jan 13, 2006
Messages
11
Programming Experience
1-3
Hello,

I have used this sql statment

Dim Stxt_qty As String = "Select sId,sQty,sDate,sTime from SStock where (sModel ='" & ScmbModel.Text & "') and (sThing='" & ScmbThing.Text & "') and (sSupplier='" & ScmbSupp.Text & "') and (sDate=#" & StxtDate.Value.ToShortDateString & "#)"

It works fine but when become 01/01/2006 (DD/MM/YYYY) OR whenever 'zero' is Prefix before day and month this string does not work means it doesn't access data from database.

NOTE:Query work good when date is 28/12/2006 OR when there is no 'zero' prefix before day and month

Thanks
 
Building literal SQL statements using string concatenation is error-prone, hard to read and insecure. DEFINITELY take vis781's advice and use parameterised commands.
 

Similar threads

Back
Top