Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   Having trouble adding Recordset into access database through ASP (http://www.velocityreviews.com/forums/t793162-having-trouble-adding-recordset-into-access-database-through-asp.html)

Anand 02-06-2004 07:23 AM

Having trouble adding Recordset into access database through ASP
 
Hi i am having trouble adding a recordset into the access database,
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
Code:

<%
' 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
%>


Bob Barrows 02-06-2004 01:18 PM

Re: Having trouble adding Recordset into access database through ASP
 
Anand wrote:
> Hi i am having trouble adding a recordset into the access database,


Already answered over in .db

Please do not multipost Anand. This is definitely a database-related
question so .asp.db was the perfect group in which to post it. Posting it
here as well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his time
to answer it here, only to find that it was already resolved in the other
group, that person may have been annoyed enough to ignore any future posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most appropriate
(again, this was not one of them), and you will want to post a question to
both groups. In that situation, you should use the cross-posting technique,
rather than posting the same message multiple times. To crosspost, put
a semicolon-delimited* list of the newsgroups to which you wish to post in
the To: header of your post and post it once. It, and any replies to it,
will appear in all the newsgroups in your list. So, if I reply in .asp.db,
my reply will also appear here in .asp.general.

* ... or whatever delimiter is recognized by your news client

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"




All times are GMT. The time now is 02:34 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.