Previous Next

Thread: javascript and vbscript question

Last post 04-30-2008 11:38 PM by steve schofield. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 04-30-2008, 10:32 PM

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    javascript and vbscript question

    I have javascript with vbscript in my adduser.asp page. 

     the code below is supposed to show you the "user name exists" alert only when the recordcount is not 0, meaning the select statement found that user in the database.

     But what it is doing is first inserting the new user (recordcount is 0) but then showing the alert saying "user name exists"

    I think it first sees recordcount as 0 but then after the inset it updates the recordcount to 1 and then shows the alert. 

     If this is happening I need to find a way to get around this.  Does anyone have any good suggestions about this?  Any code samples would be great, I'm really stumped on this.

    <CODE>

     set chkrs = server.CreateObject("adodb.recordset") chkrs.cursorlocation = 3

     chkrs.open "Select * from Tbl where user='"&trim(username)&"'", strconn

      if chkrs.recordcount = 0 Then   set regrs = server.CreateObject("adodb.recordset")   regrs.open "insert into Tbl (User) values ('"&trim(usr)&"')",strconn            %>                  <Script language="javascript">                        alert("New User Created Successfully ! ")                        window.location='somepage.asp'                  </script>                     <%      else            %>                  <Script language="javascript">                        alert("User Name Exists")                        </script>                     <%

    end if

    </CODE>
  • 04-30-2008, 10:37 PM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: javascript and vbscript question

    wow, that code looks horrible.  I dont see where you can insert code (like you can do in asp.net forum site) so it be formatted to be readable. does anyone know how to do this?  sorry about the mess

  • 04-30-2008, 11:38 PM In reply to

    Re: javascript and vbscript question

    This is not so much a code forum as much as http://forums.asp.net, I looked at your code, It looks correct but the one thing that stands out have you tried a different cursor type. 

    http://msdn.microsoft.com/en-us/library/ms967908.aspx

    I would verify the count with some 'stub' code to ensure your values are zero.  Here is an example.

    http://www.w3schools.com/ADO/prop_rs_recordcount.asp

    Steve Schofield
    Windows Server MVP - IIS
    MCTS - Windows Hosting

    http://weblogs.asp.net/steveschofield
    http://www.iislogs.com
    http://www.orcsweb.com/
    Managed Hosting Solutions
    #1 in Service and Support
Page 1 of 1 (3 items)
Page view counter