Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Posts
    36

    Unanswered: Insert Query Problem..............

    Hi ,
    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?
    Thanx
    Sajjad

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    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
    that
    checks for a valid date with isDate()
    converts the date to US-format string surrounded with #

    then
    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.

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •