the code seems to be working fine it passs and parses through all
variables just fine without showing any errors and also when i access
the recordset it displays the results, what the real issue is that the
entry is not made into the database even though i use the Update
command and i have also tried the BeginTrans and CommitTrans nothign
seems to work and i am unable to figure out wats wrong with this
code.....here is the code below...plz help me out i would really
apreciate any help...thanks
Expand|Select|Wrap|Line Numbers
- <%
- ' Connect to database
- Set conn_add = Server.CreateObject("ADODB.Connection")
- 'conn_add.mode = 3 'readWrite mode
- conn_add.Open "DSN=semda; UserID=USERIDSTRING; pwd=PWDSTRING"
- 'conn_add.BeginTrans
- if ucase(TypeName(conn_add)) = "CONNECTION" then
- response.Write("CONNECTION MADE!")
- end if
- If Request.Form("DescShort") = "" Or Request.Form("DescLong") = ""
- Then
- ErrStr = "You didn't fill in all the required fields. Please go back
- and enter all required data."
- Else 'Insert into database
- 'pulling out max_job
- Set maxJobID = Server.CreateObject("ADODB.Recordset")
- maxJobID.open "Select max(JobID) as max_job from JobList", conn_add
- Do while not maxJobID.eof
- max_job=maxJobID("max_job")
- maxJobID.MoveNext
- Loop
- response.Write("<br>MAX JOB ID IS: "& max_job &"<br>")
- max_job=max_job+1
- maxJobID.Close
- Set maxJobID= Nothing
- Set sthRecordset = Server.CreateObject("ADODB.Recordset")
- on error resume next
- sthRecordset.open "JobList",conn_add,2,3
- '2,3 adOpenDynamic=2/adOpenKeyset = 1, adLockOptimistic=3
- 'check for errors
- on error resume next
- If conn_add.Errors.count > 0 Then
- Set objErr = Server.CreateObject("ADODB.Error")
- for each objErr in conn_add.Errors
- If objErr.Number <> 0 Then
- response.Write("Number: " & objErr.Number & "<p>")
- response.Write("Description: " & objErr.Description & "<p>")
- response.Write("Source: " & objErr.Source & "<p>")
- response.Write("SQLState: " & objErr.SQLState & "<p>")
- response.Write("NativeError: " & objErr.NativeError & "<p>")
- End If
- next
- Else
- sthRecordset.AddNew
- response.Write("NEW RECORD ADDED")
- sthRecordset.Fields("JobID") = max_job
- sthRecordset.Fields("DescShort") = Request.Form("DescShort")
- sthRecordset.Fields("DescLong") = Request.Form("DescLong")
- sthRecordset.Fields("TypeID") = Request.Form("TypeID")
- sthRecordset.Fields("PayLow") = Request.Form("PayLow")
- sthRecordset.Fields("PayHi") = Request.Form("PayHi")
- sthRecordset.Fields("ContactName") = Request.Form("ContactName")
- sthRecordset.Fields("Phone") = Request.Form("Phone")
- sthRecordset.Fields("Fax") = Request.Form("Fax")
- sthRecordset.Fields("Email") = Request.Form("Email")
- sthRecordset.Fields("Web") = Request.Form("Web")
- sthRecordset.Fields("Verified") = "No"
- If Request.Form("ExpireDate") = "" Then
- sthRecordset.Fields("ExpireDate") = Date()+30
- Else
- sthRecordset.Fields("ExpireDate") = Request.Form("ExpireDate")
- End if
- sthRecordset.Fields("EnterDate") = Now()
- If sthRecordset.Fields("ExpireDate") = "" Then
- ErrStr = "There was a problem converting the expiration date you
- entered. " &_
- "Please go back and make sure you entered a date in the format
- specified."
- response.Write("<br>IN HERE<br>")
- sthRecordset.CancelUpdate
- 'conn_add.RollbackTrans
- Else
- sthRecordset.Update
- 'conn_add.CommitTrans
- JobID = sthRecordset.Fields("JobID")
- response.Write("<br>NEW RECORD ADDED TOTALY with job id: "& JobID)
- EXPdate = sthRecordset.Fields("ExpireDate")
- response.Write("<br>EXP DATE: "& EXPdate)
- End If
- sthRecordset.Close
- Set sthRecordset = Nothing
- End If
- End If
- %>