I'm really stumped by this now. I don't have any loops, I've commented out everything else so I know that I am looking at the only code that is running and it still happens.
When I create a new entry in the database, it creates 2 identicle entries.
It doesn't matter if I use AddNew() or if I use an Insert statement. You will see both in the code, I've commented out the AddNew() portion.
"Every day is like a precious gift, you have to make it count" James Birrell 1993-2001
When I create a new entry in the database, it creates 2 identicle entries.
It doesn't matter if I use AddNew() or if I use an Insert statement. You will see both in the code, I've commented out the AddNew() portion.
Code:
if (isblank(eid))
{
Response.Write("<br>eid is blank<br>")
var rstEmployers = Server.CreateObject("ADODB.RecordSet");
var rsContacts = Server.CreateObject("ADODB.RecordSet");
seedFromPage();
var mySQLStatement = "INSERT into Employer (Name, Address1, Address2, City, PostalCode, Region) "
mySQLStatement += "VALUES ('"+ employerName + "','" + address1 + "','" + address2 +"','" + city + "','";
mySQLStatement += postal + "','" +Session("region") + "')";
oConn.Execute(mySQLStatement);
mySQLStatement = "SELECT * from Employer where Name='" +employerName +"' and Region='" + Session("region") + "' order by employerID desc";
rstEmployers.Open(mySQLStatement,oConn,adOpenStatic, adLockReadOnly)
rstEmployers.MoveLast();
eid = rstEmployers("employerID").Value;
rstEmployers.Close();
Response.Write(eid);
/*rstEmployers.Open("employer", oConn, adOpenKeyset, adLockPessimistic)
if ((rstEmployers.EOF)&&(rstEmployers.BOF))
{
Response.Write("There is nothing in the recordset");
}
rstEmployers.MoveLast();
rstEmployers.Addnew();
rstEmployers.Update();
Response.Write("<br>eid = " + rstEmployers("EmployerID").value)
Response.Write("<br> now updating the content");
rstEmployers.MoveLast();
seedFromPage();
rstEmployers("Name") = employerName;
rstEmployers("Address1") = address1;
rstEmployers("Address2") = address2;
rstEmployers("city") = city;
rstEmployers("PostalCode") = postal;
rstEmployers("region")= Session("region");
Response.Write("<br>eid = " + rstEmployers("EmployerID").value)
rstEmployers.Update();
eid = rstEmployers("EmployerID").Value;
Response.Write("<br>eid = " + rstEmployers("EmployerID").value)
rstEmployers.Close();
*/
/*mySQL= "insert into employer (Name, address1, region) values ('bah','bah','peterborough')"
rsEmployers("employerID") = oConn.Execute(mySQL);
Response.Write(rsEmployers("employerID").Value);
*/
}
"Every day is like a precious gift, you have to make it count" James Birrell 1993-2001