 |
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

October 26th, 2003, 04:40 PM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Initialization error"adOpenforwardOnly"
Hi everybody
i am receiving the error regarding the initialization of adOpenForwardOnly,adLockOptimistic and adCmdTable and as i initialize it then it gives me the error"Arguments are of wrong type and are out of acceptable range or are in conflict with each other" i have also used option explicit and still the error is there
please Help
Ali
|

October 26th, 2003, 05:38 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Ali,
You may want to take a look here: http://www.adopenstatic.com/faq/800a0bb9.asp or in any of the other FAQs on that site.
If that doesn't help, I suggest you post some code so we can take a look at it.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

October 26th, 2003, 05:59 PM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi everybody
the piece of code is as follows
Dim objConn
Dim rsUsers
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source= F:\Ch15\classified_2000.mdb"
Set rsUsers = Server.CreateObject("ADODB.Recordset")
rsUsers.Open "Person", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
If Session("blnValidUser") = True and Session("PersonID") = "" Then
Dim rsPersonIDCheck
Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
Dim strSQL
Ali
|

October 26th, 2003, 06:55 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
How and where are you declaring the ad* constants? Are you using an include file, or are you declaring them in your code?
I think the error is caused by incorrect values for the ad* constants, but you'll need to post some more code before I can see how things are set up.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

October 26th, 2003, 07:36 PM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi Imar
please can u tell me how to declare constants because i havent done itand also i am not using any header file,the code is as follows:
<%Option Explicit%>
<%
Dim objConn
Dim rsUsers
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source= F:\Ch15\classified_2000.mdb"
Set rsUsers = Server.CreateObject("ADODB.Recordset")
rsUsers.Open "Person", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
If Session("blnValidUser") = True and Session("PersonID") = "" Then
Dim rsPersonIDCheck
Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
Dim strSQL
strSQL = "SELECT PersonID FROM Person " & _
"WHERE EMailAddress = '" & Session("EMailAddress") & "';"
rsPersonIDCheck.Open strSQL, objConn
If rsPersonIDCheck.EOF Then
Session("blnValidUser") = False
Else
Session("PersonID") = rsPersonIDCheck("PersonID")
End If
rsPersonIDCheck.Close
Set rsPersonIDCheck = Nothing
End If
If Session("PersonID") <> "" Then ' currently logged-on user
rsUsers.Filter = "PersonID = '" & Session("PersonID") & "'"
Else ' New session
rsUsers.Filter = "EMailAddress = '" & Request.Form("email") & "'" & _
"AND Password = '" & Request.Form("password") & "'"
If rsUsers.EOF Then ' User not found
rsUsers.AddNew ' ...so add a new record
' Else
' Email address and password matched with DB records -
' In this case we'll allow this to update user's personal details
End If
End If
' write personal details to record
rsUsers("EMailAddress") = Request.Form("email")
rsUsers("Password") = Request.Form("password")
rsUsers("FamilyName") = Request.Form("FamilyName")
rsUsers("GivenName") = Request.Form("GivenName")
rsUsers("StreetAddress1") = Request.Form("Address1")
rsUsers("StreetAddress2") = Request.Form("Address2")
rsUsers("City") = Request.Form("City")
rsUsers("State") = Request.Form("State")
rsUsers("PostalCode") = Request.Form("PostalCode")
rsUsers("Country") = Request.Form("Country")
rsUsers("Active") = True
rsUsers("LastLogin") = Now
rsUsers.Update ' update the database
Dim strName, strValue ' create session variables
For each strField in rsUsers.Fields
strName = strField.Name
strValue = strField.value
Session(strName) = strValue
Next
Session("blnValidUser") = True ' declare that current user is validated
Response.Redirect "MenuForRegisteredUsers.asp"
%>
Thanks for the help
Ali
|

October 26th, 2003, 11:38 PM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi ali
the constants file name is ADOVBS.INC (ADO library constants), it is declared as folows
Ahmed Ali
Software Developer
|

October 27th, 2003, 01:34 AM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ahmed Ali
Thanks for the help but the error remains the same
Variable Is Undefined "adOpenForwardOnly"
Ali
|

October 27th, 2003, 01:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
If you use any ADO constant, like adOpenForwardOnly etc, ASP has to know what adOpenForwardOnly really means. There are a couple of ways to tell ASP where to look for these constants:
1. Declare them yourself: Const adOpenForwardOnly = 0
Not recommended, because you have to do this on every page where you use the constant, or include your own file.
2. Include the adovbs.inc file, (found in C:\Program Files\Common Files\System\Ado by default) with the following code (you'll need to copy it to your virtual root of your website or modify the path in the statement):
3. Add a reference to the ADO dll in your global.asa. For this to work, you need to know the exact location of the DLL which can be a problem if you use an ISP or can't / don't use the global.asa.
However, imo this is the recommend way, because all constants are included directly from the source. If anything ever changes, there's no risk you have an old include file:
Modify the above path to match your location of msado15.dll
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|
 |