Help with querystring for transferring data

Results 1 to 2 of 2

Thread: Help with querystring for transferring data

  1. #1
    Join Date
    Dec 1969

    Default Help with querystring for transferring data

    Here&#039;s my code, an explanation at the bottom...<BR><BR>&#060;%<BR>Set conn = Server.CreateObject("ADODB.Connection")<BR>conn.Op en "database"<BR><BR>Set RS = Server.CreateObject("ADODB.RecordSet")<BR>RS.Open "Select * FROM UserInfoTemp", conn<BR><BR>Do While Not RS.EOF<BR> If Request.QueryString("&#039;" & RS.Fields(0) & "&#039;") = "on" Then<BR> For fnum = 0 To RS.Fields.Count-1<BR> Response.Write("Two")<BR> SQL = "INSERT INTO UserInfo (UserInfo.Fields(" & fnum & ")) VALUES (&#039;" & RS.Fields(fnum).Value & "&#039;)"<BR> conn.execute(SQL)<BR> Next <BR> End If<BR> Response.Write("One")<BR> RS.MoveNext<BR>Loop<BR><BR>%&#062;<BR><BR>I am letting an administrator decide who to approve for an account on the server and who to not approve. The administrator checks boxes in a previous page for the users it wants to approve, and sends their usernames via the querystring to this page. The pending user information is stored in UserInfoTemp, and I want to move approved records to UserInfo. I&#039;m using an If statement to determine if the record has been checked. The Response.Write "One" and Response.Write "Two" are just pieces of code I added to try to see what was going on. An output of the page has no errors and writes "One" twice, but nothing happens to the database itself... Help!

  2. #2
    Join Date
    Dec 1969

    Default You *really* have...

    ...a form field named something like &#039;BOB&#039; ?? That is, *with* the apostrophes? Something like<BR> &#060;INPUT Type="Checkbox" Name="&#039;BOB&#039;" Value="on"&#062;<BR>????<BR><BR>Because THAT is what you are looking for when you do this:<BR> If Request.QueryString("&#039;" & RS.Fields(0) & "&#039;") = "on" Then <BR><BR>I *strongly* suspect that you do *NOT* want those apostrophes there.<BR><BR>However...<BR><BR>There&#039;s another problem: If RS.Fields(0) is just a number, then it will *not* be treated as the *name* of the field but will, instead, be used as a position in the Request.QueryString array.<BR><BR>Never have a form field that is named with just a number. If you *might* have something like this:<BR> &#060;INPUT Type="Checkbox" Name="173" Value="on"&#062;<BR>Then give the name a prefix, perhaps:<BR> &#060;INPUT Type="Checkbox" Name="ID173" Value="on"&#062;<BR>and then you can do<BR> If Request.QueryString("ID" & RS.Fields(0)) = "on" <BR><BR>But, finally, I think you are going about this ALL wrong. There is no reason to go back through the recordset *again*. Just pass enough info from the &#060;FORM&#062; to allow the INSERTs to take place without a need for RS, at all.<BR><BR><BR><BR>

Posting Permissions

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