passing variables

Results 1 to 2 of 2

Thread: passing variables

  1. #1
    Join Date
    Dec 1969

    Default passing variables

    Hi,<BR><BR>I have a add page where a user enters info, which after clicking submit gets put into the database, one of the fields is called change_control_number which gets automatically assigned by the database. The user now has the option to view this info, based on the change_control_number, so I created a view page. A page now comes up with a text box called ccnsearch and a submit button. The user enters a number in the textbox and clicks submit, I then want to search the database and display all records where the change_control_number is equal to the number the user typed in the textbox.<BR>I can&#039;t figure out the select statement, here is the code I used for it.<BR><BR>dim objRS, queryStr, connStr,ccn<BR>set objRS = Server.CreateObject("ADODB.Recordset") <BR>Set connStr = Server.CreateObject("ADODB.Connection") <BR>Set ccn = ccnsearch.value<BR><BR>queryStr = "SELECT * FROM request where change_control_number = & ccn"<BR><BR>connStr.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & Server.MapPath(".") & "Database elephony.mdb;"<BR><BR>objRS.Open queryStr, connStr<BR><BR>If Not objRS.EOF Then<BR><BR>with objRS<BR><BR>Any help would be great.

  2. #2
    Join Date
    Dec 1969

    Default RE: passing variables

    queryStr = "SELECT * FROM request where change_control_number = " & ccn<BR><BR>That is okay if change_control_number is defined as a number in the database. If it is a character value you need to do <BR><BR>queryStr = "SELECT * FROM request where change_control_number = &#039;" & replace(ccn,"&#039;","&#039;&#039;") & "&#039;"

Posting Permissions

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