12-13-05, 07:31 #1Registered User
- Join Date
- Feb 2005
Unanswered: Insert Query Problem..............
I am using Asp.net(vb.net) and data base is MS Access.
this query give error to me
"Error in INSERT INTO Statemenet"
i inserted break point,and copy the query text and run this query text at MS access, this runing fine....., but here it gives error....
i also add # sign with date .....like #01/01/2005 10:50:50 PM# , but it not working....
"INSERT INTO User_Info(User_Name,Password,User_Type,Last_Login, Is_Deleted,Is_Enabled,Created_By,Edited_By,Date_Cr eated,Date_Edited) VALUES ('" & Me.UserName & "','" & Me.Passwords & "','" & Me.usertype & "'," & Me.LastLogin & "," & Me.isdeleted & "," & Me.isenabled & ",'" & Me.createdby & "','" & Me.editedby & "'," & Me.datecreated & "," & Me.dateedited & ")"
Any idea about that?
12-13-05, 08:06 #2Cavalier King Charles
- Join Date
- Dec 2002
- Préverenges, Switzerland
looks like you got it right for the strings with
blahblah '" & myStringBox & "' blahblah
now you have to do similar for the dates using # instead of '
blahblah #" & myDateBox & "# blahblah
also - you need to convert your dates to US-format (mm/dd/yyyy) if they are in ROW format. (i believe ISO format also works)
if you do a lot of this it might be worthwhile building a
public function sqlDate(inDate as Variant) as string
checks for a valid date with isDate()
converts the date to US-format string surrounded with #
blahblah " & sqlDate(myDateBox) & " blahblah
using a function makes a later switch to e.g. MSSQL much easier - just modify the function once instead of trawling through your code changing every strSQL to suit the backend.
izycurrently using SS 2008R2