dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: New Instance Of The Recordset Object

  1. #1
    Join Date
    Dec 2010
    Posts
    1

    New Instance Of The Recordset Object

    Below is the code for my insert statement, i added the code for duplicate username, it alerts if it is duplicate BUT if it ISN'T duplicate the statement (else) doesn't execute. I know i have to create a new recordset object but i cant get it to work right

    Code:
    function insertStudentP()
    {
     var id = document.getElementById("peopleid").value;
     var fn = document.getElementById("firstName").value;
     var ln = document.getElementById("lastName").value;
     var dob = document.getElementById("dob").value;
     var role = document.getElementById("role").value;
     var usr1 = document.getElementById("usr1").value;
     var pswd1 = document.getElementById("pswd1").value;
    
     var strSQL = "insert into Student(fname, lname, dob, role, usr, pswd) select('" + fn + "','" + ln + "','" + dob + "','" + role + "','" + usr1 + "','" + pswd1 + "')";
     alert("SQL statement: " + strSQL);
      var strSQL1 = "select * from student where usr ='" + usr1 +"'";
    
     var conn = AdoDB("ADODB.Connection");
    
     conn.open(conn_str, "", ""); //open my db connection
    
     // declare my dataset
     var dsStudent = new ActiveXObject("ADODB.Recordset");
    
    
    if(pswd1.length <= 7 || pswd1.length >= 20 && usr1.length <=0 || fn.length<=0 || ln.length<=0 || dob.length<=0 || role=='admin' || role=='Admin' )
     {
     alert("Doesn't meet Password Requirements(8-20 Characters); Or Fill All The Fields Out");
     }
     else
     { 
    
      dsStudent.open(strSQL1, conn, adOpenDynamic, adLockOptimistic);
    
     if(usr1 == dsStudent.fields(5))
     {
      alert("It Failed;Duplicate Username");
     }
     
     else 
     {
      alert("Power Add1"); 
     dsStudent.open(strSQL, conn, adOpenDynamic, adLockOptimistic);
      alert("insert completed");
     
     }
     
    }
    }// close insertStudent

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    This is not Visual Basic code. What language are you using?

Similar Threads

  1. How Vietnam Can Still Be Won
    By Steven Hughes in forum Architecture and Design
    Replies: 0
    Last Post: 02-19-2008, 08:07 AM
  2. Replies: 3
    Last Post: 03-21-2003, 03:23 PM
  3. Replies: 0
    Last Post: 05-08-2002, 08:22 AM
  4. Validating XML
    By Jaco de Villiers in forum XML
    Replies: 1
    Last Post: 06-01-2001, 05:50 PM
  5. Recordset does not update in business object
    By Dave Barker in forum VB Classic
    Replies: 1
    Last Post: 12-08-2000, 03:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center