UserID value

Results 1 to 4 of 4

Thread: UserID value

  1. #1
    Join Date
    Dec 1969
    Posts
    17

    Default UserID value

    I tried with this code and it worked.However, if I change the 119 to "&UserID&", then I get the syntax error. So could this be cos it is not reading the userID value?<BR><BR>&#060;%&#039;Dynamic Link<BR>Dim cnx, strQuery<BR><BR>UserID = Request.QueryString("UserID")<BR> <BR>&#039; Create and open a connection object<BR>Set cnx = Server.CreateObject("ADODB.Connection")<BR>cnx.Ope n ConnectString("Auto")<BR><BR>&#039; Build the SQL string<BR>strQuery="INSERT INTO Activity (UserID) VALUES (119)"<BR><BR>&#039; Execute the SQL against the open Connection<BR>cnx.Execute strQuery<BR>&#039; Tidy up the Connection object<BR><BR>Set cnx = Nothing<BR>%&#062;<BR><BR>The previous page has a form with GET, this is why i use Request.QueryString. should this be in the head of the document?<BR><BR>119 is the UserID value of a record in the user table.<BR><BR>Natalia

  2. #2
    Join Date
    Dec 1969
    Posts
    2,092

    Default RE: UserID value

    What is the field type in your database?<BR>Is it "int"<BR><BR>UserID = Cint(Trim(Request.QueryString("UserID")))<BR>Respo nse.Write UserID & "&#060;hr&#062;"<BR>strQuery="INSERT INTO Activity (UserID) VALUES ( & UserID &)"<BR>Response.Write strQuery & "&#060;hr&#062;"<BR><BR>Response.End<BR><BR>DE BUG DEBUG<BR><BR><BR><BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    17

    Default RE: UserID value

    it is a long integer, but i am going to try your code, thank you so much. :)

  4. #4
    Join Date
    Dec 1969
    Posts
    17

    Default SORTED!

    &#060;%&#039;Dynamic Link<BR>Dim cnx, strQuery<BR><BR>UserID =CLng(user.Value("UserID"))<BR> <BR>&#039; Create and open a connection object<BR>Set cnx = Server.CreateObject("ADODB.Connection")<BR>cnx.Ope n ConnectString("Auto")<BR><BR>&#039; Build the SQL string<BR>strQuery="INSERT INTO Activity (UserID) VALUES (" & UserID & ")"<BR><BR>&#039; Execute the SQL against the open Connection<BR>cnx.Execute strQuery<BR>&#039; Tidy up the Connection object<BR><BR>Set cnx = Nothing<BR>%&#062;<BR><BR>HAVE A VERY NICE DAY :)


Posting Permissions

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