Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

New Instance Of The Recordset Object


  • Please log in to reply

#1
Melwin

Melwin

    New Member

  • Member
  • Pip
  • 7 posts
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
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

  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP