select probem in loop

Results 1 to 2 of 2

Thread: select probem in loop

  1. #1
    Join Date
    Dec 1969

    Default select probem in loop

    I want to check that if software exit (install) it give message that software already exit <BR>If software not exit where stn_no=’”&stn_no&”’ and software=’”&software&”’ then it insert the records (software)<BR>Multiple values (software) received from asp page.<BR>I have problem in select statement (in loop) , it always give message that “software already exit”<BR><BR>if software not exit it should move to next coding and insert the records (software)<BR><BR>some time it give following error<BR><BR>Error Type:<BR>Microsoft VBScript runtime (0x800A01A8)<BR>Object required: &#039;rs&#039;<BR>/dcilweb/dcildepts/compsys/inventory/checksoftware2.asp, line 25<BR><BR><BR>How can check Mulitple values by the select statement ?<BR><BR>&#060;%<BR>stn_no=Request.Form("stn_no")< BR>software=Request.Form("software")<BR><BR><BR>fo r x = 1 to Request.Form("software").Count<BR><BR>ssql="select stn_no,software from software2 where stn_no=&#039;"& stn_no&"&#039; and software=&#039;"& Request.Form("software").Item(x)&"&#039;"<BR><BR>s et rs=cn.Execute(ssql)<BR><BR>next<BR><BR>if rs.eof=false then // line 25<BR>x=server.URLEncode("Software already Installed")<BR>Response.Redirect("inv_update_respo nse3.asp?msg=" & x)<BR><BR>else<BR><BR>for x = 1 to Request.Form("software").Count<BR><BR> sql = "insert into software2 (software,stn_no) values ("<BR> sql = sql & "&#039;" & Request.Form("software").Item(x) & "&#039;,&#039;" & stn_no & "&#039;)"<BR><BR> cn.Execute sql<BR>next<BR><BR><BR>if err.number=0 then<BR>Response.Redirect("addnew_soft7.asp")<BR>e lse<BR>Response.Redirect("wrong_entry7.asp")<BR>en d if<BR>end if<BR>%&#062;<BR><BR>Please help<BR><BR>Mateen<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: select probem in loop

    Might be more efficent to request all the checked items at once:<BR>software=Request.Form("software")<BR><BR> Which should give you a comma separated list, i.e.<BR>Windows,Dos,Solaris<BR><BR>You could then quote this and put it all in one single SQL string:<BR><BR>..and software IN (&#039;Windows&#039;,&#039;Dos&#039;,&#039;Solaris &#039;)"<BR><BR>This will eliminate the need for looping a sql command which is never a good idea.<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