473,387 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1. <%
  2. ' Connect to database
  3. Set conn_add = Server.CreateObject("ADODB.Connection")
  4. 'conn_add.mode = 3    'readWrite mode
  5. conn_add.Open "DSN=semda; UserID=USERIDSTRING; pwd=PWDSTRING"
  6.  
  7. 'conn_add.BeginTrans
  8.  
  9. if ucase(TypeName(conn_add)) = "CONNECTION" then
  10. response.Write("CONNECTION MADE!")
  11. end if
  12.  
  13.  
  14. If Request.Form("DescShort") = "" Or Request.Form("DescLong") = ""
  15. Then
  16. ErrStr = "You didn't fill in all the required fields. Please go back
  17. and enter all required data."
  18. Else    'Insert into database
  19.  
  20. 'pulling out max_job
  21. Set maxJobID = Server.CreateObject("ADODB.Recordset")
  22. maxJobID.open "Select max(JobID) as max_job from JobList", conn_add
  23. Do while not maxJobID.eof
  24. max_job=maxJobID("max_job")
  25. maxJobID.MoveNext
  26. Loop
  27. response.Write("<br>MAX JOB ID IS: "& max_job &"<br>")
  28. max_job=max_job+1
  29. maxJobID.Close
  30. Set maxJobID= Nothing
  31.  
  32. Set sthRecordset = Server.CreateObject("ADODB.Recordset")
  33. on error resume next
  34.  
  35. sthRecordset.open "JobList",conn_add,2,3
  36. '2,3    adOpenDynamic=2/adOpenKeyset = 1, adLockOptimistic=3
  37.  
  38. 'check for errors
  39. on error resume next
  40. If conn_add.Errors.count > 0 Then
  41. Set objErr = Server.CreateObject("ADODB.Error")
  42. for each objErr in conn_add.Errors
  43. If objErr.Number <> 0 Then
  44. response.Write("Number: " & objErr.Number & "<p>")
  45. response.Write("Description: " & objErr.Description & "<p>")
  46. response.Write("Source: " & objErr.Source & "<p>")
  47. response.Write("SQLState: " & objErr.SQLState & "<p>")
  48. response.Write("NativeError: " & objErr.NativeError & "<p>")
  49. End If
  50. next
  51. Else
  52. sthRecordset.AddNew
  53. response.Write("NEW RECORD ADDED")
  54. sthRecordset.Fields("JobID") = max_job
  55. sthRecordset.Fields("DescShort") = Request.Form("DescShort")
  56. sthRecordset.Fields("DescLong") = Request.Form("DescLong")
  57. sthRecordset.Fields("TypeID") = Request.Form("TypeID")
  58. sthRecordset.Fields("PayLow") = Request.Form("PayLow")
  59. sthRecordset.Fields("PayHi") = Request.Form("PayHi")
  60. sthRecordset.Fields("ContactName") = Request.Form("ContactName")
  61. sthRecordset.Fields("Phone") = Request.Form("Phone")
  62. sthRecordset.Fields("Fax") = Request.Form("Fax")
  63. sthRecordset.Fields("Email") = Request.Form("Email")
  64. sthRecordset.Fields("Web") = Request.Form("Web")
  65. sthRecordset.Fields("Verified") = "No"
  66. If Request.Form("ExpireDate") = "" Then
  67. sthRecordset.Fields("ExpireDate") = Date()+30
  68. Else
  69. sthRecordset.Fields("ExpireDate") = Request.Form("ExpireDate")
  70. End if
  71. sthRecordset.Fields("EnterDate") = Now()
  72.  
  73. If sthRecordset.Fields("ExpireDate") = "" Then
  74. ErrStr = "There was a problem converting the expiration date you
  75. entered. " &_
  76. "Please go back and make sure you entered a date in the format
  77. specified."
  78. response.Write("<br>IN HERE<br>")
  79. sthRecordset.CancelUpdate
  80. 'conn_add.RollbackTrans
  81. Else
  82. sthRecordset.Update
  83. 'conn_add.CommitTrans
  84. JobID = sthRecordset.Fields("JobID")
  85. response.Write("<br>NEW RECORD ADDED TOTALY with job id: "& JobID)
  86. EXPdate = sthRecordset.Fields("ExpireDate")
  87. response.Write("<br>EXP DATE: "& EXPdate)
  88. End If
  89. sthRecordset.Close
  90. Set sthRecordset = Nothing
  91. End If
  92. End If
  93. %>
  94.  
Jul 19 '05 #1
1 2570
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"
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Peroq | last post by:
Hi all I'm not sure ASP is the problem, but my SQL statement seems fine to me. This works fine : strSQL = "SELECT .* FROM _RechPat INNER JOIN NivPatri ON .cod_niv = NivPatri.cod_niv WHERE...
7
by: Alex | last post by:
Hi all, I've found a module that I think will help me combine fields properly, but I'm unsure how to add or use it with Access 2000. Below is the module I'd like to add: ...
1
by: Will | last post by:
Hi, I have a form which calculates a final cost (frmWorkCosts, data stored in tblWorkCosts) and once calculated adds this final cost (Which isn't saved in tblWorkCosts) into a different table...
9
by: TD | last post by:
I am trying to add transactions to my code. The original code worked fine until I followed an example to setup transactions, now the code does strange things, but no error messages. Could...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
1
by: MLH | last post by:
Am having trouble with the filter property setting below. Would like to filter the listing to car makes beginning with "D". I'm blowing it on the filter spec somehow??? Sub OpenRecordsetX() ...
1
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following...
2
by: ARC | last post by:
Just curious if anyone is having issues with Acc 2007 once the number of objects and complexity increases? I have a fairly large app, with many linked tables, 100's of forms, queries, reports, and...
1
damonreid
by: damonreid | last post by:
Access 2003 Microsoft Windows XP Pro Hey, I am currently pulling my hair out here. I have a Form for adding new projects to a database, the only problem is that when I close the form it doesn't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.