Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Explicit and AddNew Errors

Status
Not open for further replies.

DaiDreamer

Programmer
May 8, 2001
31
US
Hi! For some reason my code doesn't like option explicit or Rsadd.addnew

The frist one comes up with this error:


Microsoft VBScript compilation error '800a0400'

Expected statement

/bureauofminere/frdocinvetory/NewAdded.asp, line 10

option explicit


and the other one with this

ADODB.Recordset error '800a0cb3'

The operation requested by the application is not supported by the provider.

/bureauofminere/frdocinvetory/NewAdded.asp, line 214


here's my code. The lines were the errors are bolded. (sorry about the mess at the top...)

<!DOCTYPE HTML PUBLIC &quot;-//IETP//DTD HTML//EN&quot;>
<html>

<head>

<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>

<title>Records Added!</title>
<%@ Language=VBScript %>
<% option explicit%>
<%
dim section1, section2, count, section3, section4
Dim BORDocNum1, BORDocNum2, BORDocNum3, BORDocNum4, DocType1, DocType2
Dim DocType3, DocType4, DateofRequire1, DateofRequire2, DateofRequire3, DateofRequire4
dim Desc1, Desc2, Desc3, Desc4, Mine1, Mine2, Mine3, Mine4, Owner1, Owner2, Owner3, Owner4
Dim DocNum1, DocNum2, Docnum3, Docnum4, Issue1, Issue2, Issue3, Issue4, Amount1, Amount2, Amount3, Amount4, ExDate1, ExDate2, ExDate3, ExDate4, IssDate1, IssDate2, IssDate3, IssDate4, Return1, Return2, Return3, Return4

CheckFields()

Function CheckFields()
dim errors, message, fieldcounter, Sectionconn, Sectionrs, Docconn,Docrs,strSQLQuery, strSQLQuery2
Count=0
Errors=0
Message=&quot;&quot;
FieldCounter=1


' Database Stuff to get Section Name
set Sectionconn = server.createobject(&quot;ADODB.Connection&quot;)
sectionconn.Open &quot;DSN=SuretyDNS&quot;
Session.timeout = 15
Set Session(&quot;MyDB_conn&quot;) = sectionconn

strSQLQuery = &quot;SELECT * FROM Sections&quot;
Set Sectionrs = server.CreateObject(&quot;ADODB.Recordset&quot;)
sectionrs.Open strSQLQuery, sectionconn, 3, 3
'Set sectionrs = server.CreateObject(&quot;ADODB.Recordset&quot;)

set Docconn = server.createobject(&quot;ADODB.Connection&quot;)
Docconn.Open &quot;DSN=SuretyDNS&quot;
Session.timeout = 15
Set Session(&quot;MyDB_conn2&quot;) = Docconn

strSQLQuery2 = &quot;SELECT * FROM DocumentTypes&quot;
Set docrs = server.CreateObject(&quot;ADODB.Recordset&quot;)
docrs.Open strSQLQuery2, docconn, 3, 3
'Set docrs = CreateObject(&quot;ADODB.Recordset&quot;)
For Fieldcounter = 1 to 4
Select Case Fieldcounter
Case 1

testing=0
section1=request.form(&quot;SectionName1&quot;)
response.write section1
If SectionName1 <> &quot;fdk&quot; then
Count=Count+1
response.write &quot;test&quot;
BORDocNum1=request.form(&quot;BRDocNum1&quot;)
If BORDocNum1=&quot;&quot; then'from form
Errors=Errors+1
response.write &quot;case1a&quot;
message=Message+&quot;Need to have Basis of Requirement Document Number in Line 1. &quot;
Else
do until sectionrs.eof
response.write section1 & sectionrs(&quot;Code&quot;) & &quot;<br>&quot;
if Section1=sectionrs(&quot;Code&quot;) then 'valid
testing=1
response.write &quot; valid&quot;

end if
sectionrs.movenext
loop
if testing=0 then
Errors=Errors+1
message=Message+&quot;Invalid Section Name in Line 1. &quot;
end if
DocType1=request.form(&quot;BRDocType1&quot;)
If doctype1 = &quot;&quot; then'invalid
errors = errors +1
message=message + &quot;Invaild DocType in Line 1. &quot;
end if
if Errors >0 then
Response.write(message)
else
AddToDatabase()
end if
end if
end if
Case 2
testing=0
section2=request.form(&quot;SectionName2&quot;)
If Section2 <>&quot;&quot; then
Count=Count+1
BORDocNum2=request.form(&quot;BRDocNum2&quot;)
If BORDocNum2=&quot;&quot; then 'from form
Errors=Errors+1
message=Message+&quot;Need to have Basis of Requirement Document Number in Line 2. &quot;
Else
do until sectionrs.eof

if Section2=sectionrs(&quot;Code&quot;) then'valid
testing=1
response.write &quot; valid&quot;
end if
sectionrs.movenext
loop
if testing=0 then
Errors=Errors+1
message=Message+&quot;Invalid Section Name in Line 2. &quot;
end if
DocType2=request.form(&quot;BRDocType2&quot;)
If doctype1 <>&quot;&quot; then 'invalid
errors = errors +1
message=message + &quot;Invaild DocType in Line 2. &quot;
end if
if Errors >0 then
response.write (message)
else
AddToDatabase()
end if
end if
end if
Case 3
testing=0
section3=request.form(&quot;SectionName3&quot;)
If Section3 <>&quot;&quot; then
Count=Count+1
BORDocNum3=request.form(&quot;BRDocNum3&quot;)
If BORDocNum3=&quot;&quot; then'from form
Errors=Errors+1
message=Message+&quot;Need to have Basis of Requirement Document Number in Line 3. &quot;
Else
do until sectionrs.eof
if Section3=sectionrs(&quot;Code&quot;) then'valid
testing=1
response.write &quot; valid&quot;
end if
sectionrs.movenext
loop
if testing=0 then
Errors=Errors+1
message=Message+&quot;Invalid Section Name in Line 3. &quot;
end if

DocType3=request.form(&quot;BRDocType3&quot;)
If doctype1 <>&quot;&quot; then'invalid
errors = errors +1
message=message + &quot;Invaild DocType in Line 3. &quot;
end if
if Errors >0 then
response.write (message)
else
AddToDatabase()
end if
end if
end if
Case 4
testing=0
section4=request.form(&quot;SectionName4&quot;)
If Section4 <>&quot;&quot; then
Count=Count+1
BORDocNum4=request.form(&quot;BRDocNum4&quot;)
If BORDocNum4=&quot;&quot; then 'from form
Errors=Errors+1
message=Message+&quot;Need to have Basis of Requirement Document Number in Line 4. &quot;
Else
do until sectionrs.eof
if Section4=sectionrs(&quot;Code&quot;) then'valid
testing=1
response.write &quot; valid&quot;

end if
sectionrs.movenext
loop
if testing=0 then
Errors=Errors+1
message=Message+&quot;Invalid Section Name in Line 4. &quot;
end if
DocType4=request.form(&quot;BRDocType4&quot;)
If doctype1 <>&quot;&quot; then'invalid
errors = errors +1
message=message + &quot;Invaild DocType in Line 4. &quot;
end if
if Errors >0 then
response.write (message)
else
AddToDatabase()
end if
end if
end if
end select
next
sectionconn.close
docconn.close
set sectionconn=nothing
set docconn = nothing
end function 'CheckFields()

Function AddtoDatabase()
set ADDconn = server.createobject(&quot;ADODB.Connection&quot;)
ADDconn.Open &quot;DSN=SuretyDNS&quot;
Session.timeout = 15
Set Session(&quot;MyDB_conn&quot;) = ADDconn
response.write &quot;addtodatabase&quot;
Set RsAdd = server.CreateObject(&quot;ADODB.Recordset&quot;)
Set RsAdd.ActiveConnection = ADDconn
RsAdd.Open &quot;InventoryOfSuretyDocuments&quot;

For counter = 1 to count
Select case Counter

case 1

RsAdd.AddNew
RsAdd.Fields(&quot;Section Name&quot;)= section1
RsAdd.Fields(&quot;Date of Requirement&quot;)=DateofRequire1
DocType1=request.form(&quot;BRDocType1&quot;)
RsAdd.Fields(&quot;BOR Document Type&quot;)= DocType1
RsAdd.Fields(&quot;BOR Document Number&quot;)= BORDocNum1
Desc1=request.form(&quot;Reason1&quot;)
RsAdd.Fields(&quot;BOR Description of Reason&quot;)=Desc1
Mine1=request.form(&quot;Mine1&quot;)
RsAdd.Fields(&quot;Mine, Program, or Parcel&quot;)=Mine1
Owner1=request.form(&quot;Applicant1&quot;)
RsAdd.Fields(&quot;Applicant/Landowner&quot;)=Owner1
DocNum1=request.form(&quot;DocNum1&quot;)
RsAdd.Fields(&quot;Document Number&quot;)=DocNum1
Issue1=request.form(&quot;Issued1&quot;)
RsAdd.Fields(&quot;Issued By&quot;)=Issue1
Amount1=request.form(&quot;Amount1&quot;)
RsAdd.Fields(&quot;Amount&quot;)=Amount1
IssDate1=request.form(&quot;DateIssued1&quot;)
RsAdd.Fields(&quot;Date Issued&quot;)=IssDate1
ExDate1=request.form(&quot;Expiration1&quot;)
RsAdd.Fields(&quot;Expiration Date&quot;)=ExDate1
Return1=request.form(&quot;ReturnDate1&quot;)
RsAdd.Fields(&quot;Returned Date&quot;)=Return1
RsAdd.Update

case 2
RsAdd.AddNew
RsAdd.Fields(&quot;Section Name&quot;)= section2
RsAdd.Fields(&quot;Date of Requirement&quot;)=DateofRequire2
DocType2=request.form(&quot;BRDocType2&quot;)
RsAdd.Fields(&quot;BOR Document Type&quot;)= DocType2
RsAdd.Fields(&quot;BOR Document Number&quot;)= BORDocNum2
Desc2=request.form(&quot;Reason2&quot;)
RsAdd.Fields(&quot;BOR Description of Reason&quot;)=Desc2
Mine2=request.form(&quot;Mine2&quot;)
RsAdd.Fields(&quot;Mine, Program, or Parcel&quot;)=Mine2
Owner2=request.form(&quot;Applicant2&quot;)
RsAdd.Fields(&quot;Applicant/Landowner&quot;)=Owner2
DocNum2=request.form(&quot;DocNum2&quot;)
RsAdd.Fields(&quot;Document Number&quot;)=DocNum2
Issue2=request.form(&quot;Issued2&quot;)
RsAdd.Fields(&quot;Issued By&quot;)=Issue2
Amount2=request.form(&quot;Amount2&quot;)
RsAdd.Fields(&quot;Amount&quot;)=Amount2
IssDate2=request.form(&quot;DateIssued2&quot;)
RsAdd.Fields(&quot;Date Issued&quot;)=IssDate2
ExDate2=request.form(&quot;Expiration2&quot;)
RsAdd.Fields(&quot;Expiration Date&quot;)=ExDate2
Return2=request.form(&quot;ReturnDate2&quot;)
RsAdd.Fields(&quot;Returned Date&quot;)=Return2
RsAdd.Update

case 3

RsAdd.AddNew
RsAdd.Fields(&quot;Section Name&quot;)= section3
RsAdd.Fields(&quot;Date of Requirement&quot;)=DateofRequire3
DocType3=request.form(&quot;BRDocType3&quot;)
RsAdd.Fields(&quot;BOR Document Type&quot;)= DocType3
RsAdd.Fields(&quot;BOR Document Number&quot;)= BORDocNum3
Desc3=request.form(&quot;Reason3&quot;)
RsAdd.Fields(&quot;BOR Description of Reason&quot;)=Desc3
Mine3=request.form(&quot;Mine3&quot;)
RsAdd.Fields(&quot;Mine, Program, or Parcel&quot;)=Mine3
Owner3=request.form(&quot;Applicant3&quot;)
RsAdd.Fields(&quot;Applicant/Landowner&quot;)=Owner3
DocNum3=request.form(&quot;DocNum3&quot;)
RsAdd.Fields(&quot;Document Number&quot;)=DocNum3
Issue3=request.form(&quot;Issued3&quot;)
RsAdd.Fields(&quot;Issued By&quot;)=Issue3
Amount3=request.form(&quot;Amount3&quot;)
RsAdd.Fields(&quot;Amount&quot;)=Amount3
IssDate3=request.form(&quot;DateIssued3&quot;)
RsAdd.Fields(&quot;Date Issued&quot;)=IssDate3
ExDate3=request.form(&quot;Expiration3&quot;)
RsAdd.Fields(&quot;Expiration Date&quot;)=ExDate3
Return3=request.form(&quot;ReturnDate3&quot;)
RsAdd.Fields(&quot;Returned Date&quot;)=Return3
RsAdd.Update

Case 4

RsAdd.AddNew
RsAdd.Fields(&quot;Section Name&quot;)= section4
RsAdd.Fields(&quot;Date of Requirement&quot;)=DateofRequire4
DocType4=request.form(&quot;BRDocType4&quot;)
RsAdd.Fields(&quot;BOR Document Type&quot;)= DocType4
RsAdd.Fields(&quot;BOR Document Number&quot;)= BORDocNum4
Desc4=request.form(&quot;Reason4&quot;)
RsAdd.Fields(&quot;BOR Description of Reason&quot;)=Desc4
Mine4=request.form(&quot;Mine4&quot;)
RsAdd.Fields(&quot;Mine, Program, or Parcel&quot;)=Mine4
Owner4=request.form(&quot;Applicant4&quot;)
RsAdd.Fields(&quot;Applicant/Landowner&quot;)=Owner4
DocNum4=request.form(&quot;DocNum4&quot;)
RsAdd.Fields(&quot;Document Number&quot;)=DocNum4
Issue4=request.form(&quot;Issued4&quot;)
RsAdd.Fields(&quot;Issued By&quot;)=Issue4
Amount4=request.form(&quot;Amount4&quot;)
RsAdd.Fields(&quot;Amount&quot;)=Amount4
IssDate4=request.form(&quot;DateIssued4&quot;)
RsAdd.Fields(&quot;Date Issued&quot;)=IssDate4
ExDate4=request.form(&quot;Expiration4&quot;)
RsAdd.Fields(&quot;Expiration Date&quot;)=ExDate4
Return4=request.form(&quot;ReturnDate4&quot;)
RsAdd.Fields(&quot;Returned Date&quot;)=Return4
RsAdd.Update
end select
next
ADDConn.close
ADDconn=nothing
Response.write inttostr(count) & &quot; New Records Added.&quot;
end function 'AddtoDatabase()
%>
</head>
<body>

</body>

</htmL>


Thanks!

DaiDreamer
 
I can answer your first question:

<% Option Explicit %> must occur in your ASP page before any HTML code or script commands. So take it (and the &quot;<%@ LANGUAGE&quot; directive) all the way up to the top.
 
Function AddtoDatabase()
set ADDconn = server.createobject(&quot;ADODB.Connection&quot;)
ADDconn.Open &quot;DSN=SuretyDNS&quot;


Typo? Should it be SuretyDSN?
 
Comment:

Function AddtoDatabase()
set ADDconn = server.createobject(&quot;ADODB.Connection&quot;)
ADDconn.Open &quot;DSN=SuretyDNS&quot;
Session.timeout = 15
Set Session(&quot;MyDB_conn&quot;) = ADDconn


Caching objects in the Session is considered a Very Bad Thing.

See:
Look at Tip #5.
 
ADODB.Recordset error '800a0cb3'

The operation requested by the application is not supported by the provider.


Is this an Oracle database?? See
{Sorry, the forum software hosed the link. You'll have to type it in.}

In any case, your default cursor is most likely the problem.
 
No, it is an access database. The DSN name is correct. I flipped the letters on the server. I commented out the &quot;Set Session(&quot;MyDB_conn&quot;) = ADDconn&quot; and it still comes up with the same error.

Thanks for the help for my frist problem. That works fine now!

DaiDreamer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top