Results 1 to 11 of 11

Thread: Problem in INSERT [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Problem in INSERT [RESOLVED]

    Hello everybody,

    I am facing a problem in inserting record in Access database. Here is the short code snippet, which gives exception "Syntax error in INSERT INTO statement", however if I print the query by uncommenting the Response.Write line and copy the query and paste it in access and run, it runs well.

    VB Code:
    1. ' Insert
    2.         Set Rs = Conn.Execute("SELECT [User].[UserName] FROM [User] WHERE [User].[UserName] = '" & UserName & "' AND [User].[IsDeleted] = False")      
    3.         If Rs.EOF Then
    4.             Dim InsertSql
    5.             InsertSql = "INSERT INTO [User] (Name,UserName,Password,IsAdmin,IsSupervisor,IsDeleted) VALUES('" & FullName & "','" & UserName & "','" & Password & "'," & IsAdmin & "," & IsSupervisor & ",False)"
    6.             'Response.Write(InsertSql)
    7.             'Response.End
    8.             Cmd.ActiveConnection = Conn
    9.             Cmd.CommandText = InsertSql
    10.             Cmd.Execute()
    11.             'Set Rs = Conn.Execute(InsertSql)
    12.             Response.Redirect("User.asp?Message=UserAdded")
    13.         Else
    14.             Response.Redirect("User.asp?Message=UserFound")
    15.         End If
    Last edited by usamaalam; Jul 10th, 2005 at 03:18 PM. Reason: RESVOLED

Posting Permissions

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



Click Here to Expand Forum to Full Width