|
 |
asp_databases thread: access autonumber
Message #1 by crystalightening@h... on Fri, 20 Apr 2001 22:21:31
|
|
Hello everyone :-)
Why can't it find the autonumber in my db? I appreciate all your help.
ADODB.Fields error '800a0cc1'
ADO could not find the object in the collection corresponding to the name
or ordinal reference requested by the application.
/guestbook7.asp, line 40
------------------------------------------------------------------------
asp code:
<% @LANGUAGE = VBScript %>
<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
Dim con,MessageDisplay, Rs
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4
if (Request.form("first_name") <>"" or Request.form("last_name") <>"" or
Request.form("email") <>"") then
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open "DSN=DB2774A;UID=2774;PWD=156515"
con.BeginTrans ' Start the Transaction this will need to be rolled back if
there are errors anywhere.
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.ActiveConnection = con
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
Rs.Source = "customer" ' This is the Table Name
Rs.Open
Rs.AddNew
RS("last_name") = Request.form("last_name")
RS("first_name") = Request.form("first_name")
RS("email") = Request.form("email")
RS("company_name") = Request.form("company_name")
RS.Update
' error occurs here
Id = Rs("Id") ' This Returns the Id of the record that was just inserted.
rs.Close
On Error Resume Next
rs.Source = "mailing_list_guestbook" ' Open the colors table so we can
insert the data.
rs.open
Rs.AddNew
Rs("id") = Id
Rs("juiceplus") = Request.form("juiceplus")
Rs("nadn") = Request.form("nadn")
Rs("humor_digest") = Request.form("humor_digest")
Rs.Update ' Write the data to the table.
If con.Errors.Count > 0 Then
On Error Goto 0
con.RollBackTrans
MessageDisplay = "Errors"
Else
con.CommitTrans
MessageDisplay = "Your information has been recorded"
End If
On Error Goto 0
On Error Goto 0
' Close out the open connection and RS
Rs.Close
Set Rs = Nothing
con.Close
Set con = Nothing
Else
Response.Write "Please enter a first, last name or email address and
resubmit. Click the back button in your browser to get back to the
Guestbook form. Thank you!"
End If
%>
<html>
<head>
</head>
<body>
<%= MessageDisplay %>
</body>
</html>
Crystal
Message #2 by UseLess@n... on Fri, 20 Apr 2001 22:47:54 +0100
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0C9E3.8EF6FF40
Content-Type: text/plain;
charset="iso-8859-1"
I'm no expert but...
Option Explicit and no Dim Id means Id will not be given the value of
rs("id") as ID was not declared...
Hey but I could be wrong... it has been known...
-----Original Message-----
From: crystalightening@h... [mailto:crystalightening@h...]
Sent: Friday, April 20, 2001 11:22 PM
To: ASP Databases
Subject: [asp_databases] access autonumber
Hello everyone :-)
Why can't it find the autonumber in my db? I appreciate all your help.
ADODB.Fields error '800a0cc1'
ADO could not find the object in the collection corresponding to the name
or ordinal reference requested by the application.
/guestbook7.asp, line 40
------------------------------------------------------------------------
asp code:
<% @LANGUAGE = VBScript %>
<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
Dim con,MessageDisplay, Rs
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4
if (Request.form("first_name") <>"" or Request.form("last_name") <>"" or
Request.form("email") <>"") then
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open "DSN=DB2774A;UID=2774;PWD=156515"
con.BeginTrans ' Start the Transaction this will need to be rolled back if
there are errors anywhere.
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.ActiveConnection = con
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
Rs.Source = "customer" ' This is the Table Name
Rs.Open
Rs.AddNew
RS("last_name") = Request.form("last_name")
RS("first_name") = Request.form("first_name")
RS("email") = Request.form("email")
RS("company_name") = Request.form("company_name")
RS.Update
' error occurs here
Id = Rs("Id") ' This Returns the Id of the record that was just inserted.
rs.Close
On Error Resume Next
rs.Source = "mailing_list_guestbook" ' Open the colors table so we can
insert the data.
rs.open
Rs.AddNew
Rs("id") = Id
Rs("juiceplus") = Request.form("juiceplus")
Rs("nadn") = Request.form("nadn")
Rs("humor_digest") = Request.form("humor_digest")
Rs.Update ' Write the data to the table.
If con.Errors.Count > 0 Then
On Error Goto 0
con.RollBackTrans
MessageDisplay = "Errors"
Else
con.CommitTrans
MessageDisplay = "Your information has been recorded"
End If
On Error Goto 0
On Error Goto 0
' Close out the open connection and RS
Rs.Close
Set Rs = Nothing
con.Close
Set con = Nothing
Else
Response.Write "Please enter a first, last name or email address and
resubmit. Click the back button in your browser to get back to the
Guestbook form. Thank you!"
End If
%>
<html>
<head>
</head>
<body>
<%= MessageDisplay %>
</body>
</html>
Crystal
---
SoftArtisans helps developers build robust, scalable Web applications!
Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
File uploads: http://www.softartisans.com/saf.html
Transactional file management: http://www.softartisans.com/saf1.html
Scalability: http://www.softartisans.com/saxsession.html
ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
Message #3 by "Charles Feduke" <webmaster@r...> on Fri, 20 Apr 2001 18:08:34 -0400
|
|
Personally, I'd do this (which is less resource intensive on the
server):
Set conConnection = CreateObject("ADODB.Connection")
Set rsRecordset = CreateObject("ADODB.Recordset")
Private Function sNormal(sString)
sNormal = Replace(Request.Form(sString), "'", "''")
End Function
conConnection = "DSN=DB2774A;UID=2774;PWD=156515"
conConnection.Execute "INSERT INTO customer " & _
"(last_name, first_name, email, company_name) VALUES (" & _
"'" & sNormal("last_name") & "', " & _
"'" & sNormal("first_name") & "', " & _
"'" & sNormal("email") & "', " & _
"'" & sNormal("company_name") & ")", , adCmdText + adExecuteNoRecords
rsRecordset.Open "SELECT id FROM customer WHERE " & _
"last_name = '" & sNormal("last_name") & "' AND " & _
"first_name = '" & sNormal("first_name") & "' AND " & _
"company_name = '" & sNormal("company_name") & "'", conConnection, _
adOpenForwardOnly + adCmdText
sID = rsRecordset("id")
Of course you could just do SELECT MAX(id) FROM customer to return the last
ID entered if you don't think you'll have too many connections updating the
database at a time.
- Chuck
----- Original Message -----
From: <crystalightening@h...>
To: "ASP Databases" <asp_databases@p...>
Sent: Friday, April 20, 2001 10:21 PM
Subject: [asp_databases] access autonumber
> Hello everyone :-)
> Why can't it find the autonumber in my db? I appreciate all your help.
>
> ADODB.Fields error '800a0cc1'
> ADO could not find the object in the collection corresponding to the name
> or ordinal reference requested by the application.
>
> /guestbook7.asp, line 40
>
> ------------------------------------------------------------------------
> asp code:
>
> <% @LANGUAGE = VBScript %>
> <% Option Explicit %>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <%
> Dim con,MessageDisplay, Rs
>
> Const adOpenForwardOnly = 0
> Const adOpenKeyset = 1
> Const adOpenDynamic = 2
> Const adOpenStatic = 3
> Const adLockReadOnly = 1
> Const adLockPessimistic = 2
> Const adLockOptimistic = 3
> Const adLockBatchOptimistic = 4
>
>
>
> if (Request.form("first_name") <>"" or Request.form("last_name") <>"" or
> Request.form("email") <>"") then
>
> ' Creating Connection Object and opening the database
> Set con = Server.CreateObject("ADODB.Connection")
> con.Open "DSN=DB2774A;UID=2774;PWD=156515"
>
> con.BeginTrans ' Start the Transaction this will need to be rolled back if
> there are errors anywhere.
>
> Set Rs = Server.CreateObject("ADODB.Recordset")
> Rs.ActiveConnection = con
> Rs.CursorType = adOpenKeyset
> Rs.LockType = adLockOptimistic
> Rs.Source = "customer" ' This is the Table Name
> Rs.Open
> Rs.AddNew
> RS("last_name") = Request.form("last_name")
> RS("first_name") = Request.form("first_name")
> RS("email") = Request.form("email")
> RS("company_name") = Request.form("company_name")
> RS.Update
>
> ' error occurs here
>
> Id = Rs("Id") ' This Returns the Id of the record that was just inserted.
>
> rs.Close
>
> On Error Resume Next
> rs.Source = "mailing_list_guestbook" ' Open the colors table so we can
> insert the data.
> rs.open
> Rs.AddNew
> Rs("id") = Id
> Rs("juiceplus") = Request.form("juiceplus")
> Rs("nadn") = Request.form("nadn")
> Rs("humor_digest") = Request.form("humor_digest")
>
> Rs.Update ' Write the data to the table.
> If con.Errors.Count > 0 Then
> On Error Goto 0
> con.RollBackTrans
> MessageDisplay = "Errors"
> Else
> con.CommitTrans
> MessageDisplay = "Your information has been recorded"
> End If
> On Error Goto 0
> On Error Goto 0
>
> ' Close out the open connection and RS
> Rs.Close
> Set Rs = Nothing
>
> con.Close
> Set con = Nothing
> Else
>
> Response.Write "Please enter a first, last name or email address and
> resubmit. Click the back button in your browser to get back to the
> Guestbook form. Thank you!"
> End If
> %>
>
> <html>
> <head>
> </head>
> <body>
> <%= MessageDisplay %>
> </body>
> </html>
>
>
> Crystal
>
Message #4 by Peter Zahos <pzahos@s...> on Mon, 23 Apr 2001 09:15:24 +0800
|
|
This is what I did.
Play around with it!
--SQL Server 7 stored procedure
--**************************************************************************
***********************************************
CREATE PROCEDURE GetReceiptNumber
@Name1 varchar(30),
@Name2 char(30),
@Address1 char(30),
@Address2 char(30),
@Address3 char(30),
@Receiptnumber int output -- receipt Number
As
insert into tblReReceipt (ReceiptName1, ReceiptName2, ReceiptAddress1,
ReceiptAddress2, ReceiptAddress3, BalanceFlag, BankDeposit, VoidStatus)
values (@Name1, @Name2, @Address1, @Address2, @Address3, 'N', 'N', 'N')
select @Receiptnumber = @@IDENTITY
--**************************************************************************
**********************************************
____________________________________________________________________________
___________________________________________
'ASP page code. VBScript using ADO
'***************************************************************************
********************************************
Set Conn = Server.CreateObject("ADODB.Connection")
Set Cmd = Server.CreateObject("ADODB.Command")
Conn.Open session("connectionString")
Set Cmd.ActiveConnection = Conn
Cmd.CommandText = "GetReceiptNumber"
Cmd.CommandType = adCmdStoredProc
Cmd.Parameters.Append Cmd.CreateParameter("@RetVal", adinteger,
adParamReturnValue)
Cmd.Parameters.Append Cmd.CreateParameter("@Name1", adVarChar, adParamInput,
50)
Cmd.Parameters.Append Cmd.CreateParameter("@Name2", adVarChar, adParamInput,
50)
Cmd.Parameters.Append Cmd.CreateParameter("@Address1", adVarChar,
adParamInput, 50)
cmd.Parameters.Append Cmd.CreateParameter("@Address2", adVarChar,
adParamInput, 50)
cmd.Parameters.Append Cmd.CreateParameter("@Address3", adVarChar,
adParamInput, 50)
cmd.Parameters.Append Cmd.CreateParameter("@ReceiptNumber", adInteger,
adParamOutput)
session("ReceiptNumber") = cmd("@ReceiptNumber")
set cmd = nothing
set conn = nothing
'***************************************************************************
********************************************
It is the @@IDENTITY in the stored procedure you need.
Pete
Message #5 by "Ken Schaefer" <ken@a...> on Mon, 23 Apr 2001 18:29:11 +1000
|
|
or, how about SELECT @@Identity - much better:
http://www.adopenstatic.com/experiments/fastestautonumber.asp
Works with the Jet OLEDB 4.0 Provider
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "Charles Feduke" <webmaster@r...>
To: "ASP Databases" <asp_databases@p...>
Sent: Saturday, April 21, 2001 8:08 AM
Subject: [asp_databases] Re: access autonumber
: Personally, I'd do this (which is less resource intensive on the
: server):
:
: Set conConnection = CreateObject("ADODB.Connection")
: Set rsRecordset = CreateObject("ADODB.Recordset")
:
: Private Function sNormal(sString)
: sNormal = Replace(Request.Form(sString), "'", "''")
: End Function
:
: conConnection = "DSN=DB2774A;UID=2774;PWD=156515"
: conConnection.Execute "INSERT INTO customer " & _
: "(last_name, first_name, email, company_name) VALUES (" & _
: "'" & sNormal("last_name") & "', " & _
: "'" & sNormal("first_name") & "', " & _
: "'" & sNormal("email") & "', " & _
: "'" & sNormal("company_name") & ")", , adCmdText + adExecuteNoRecords
:
: rsRecordset.Open "SELECT id FROM customer WHERE " & _
: "last_name = '" & sNormal("last_name") & "' AND " & _
: "first_name = '" & sNormal("first_name") & "' AND " & _
: "company_name = '" & sNormal("company_name") & "'", conConnection, _
: adOpenForwardOnly + adCmdText
:
: sID = rsRecordset("id")
:
: Of course you could just do SELECT MAX(id) FROM customer to return the
last
: ID entered if you don't think you'll have too many connections updating
the
: database at a time.
:
: - Chuck
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #6 by "crystal davis" <crystalightening@h...> on Thu, 26 Apr 2001 15:22:11 -0400
|
|
<html><DIV>
<P>Chuck,</P>
<P>I want to thank you for your help. I have tried you code and I am running into an error</P>
<P><FONT face=Arial size=2> Microsoft OLE DB Provider for ODBC Drivers</FONT> <FONT face=Arial
size=2>error '80040e10'</FONT> <BR><FONT face=Arial size=2>[Microsoft][ODBC Microsoft Access Driver] Too few
parameters. Expected 1.</FONT> <BR><FONT face=Arial size=2>/guestbook22.asp</FONT><FONT face=Arial
size=2>, line 27</FONT> </P>
<P>-----------------------------------------</P>
<P>This line 27 down:::::::</P>
<P>rsRecordset.Open "SELECT id FROM customer WHERE " & _<BR> "last_name = '" &
sNormal("last_name") & "' AND " & _<BR> "first_name = '" & sNormal("first_name") & "' AND "
& _<BR> "company_name = '" & sNormal("company_name") & "'" ,
conConnection<BR>-----------------------------------------------------------------------------<BR>When I put in the
variables adOpenForwardOnly + adCmdText. It gave me another error that those two variables weren't defined. I assume
they are functions. Anyway when I take out the conConnection then I get an error "invalid connection" Help! Oh! in my
access db table customer I have the following fields last_name, first_name, address, city, state, country, telephone, cell_phone,
email, company_name</P>
<P>Thanks for you help.
Crystal<BR><BR></P></DIV>
<DIV></DIV>
<DIV></DIV>>From: "Charles Feduke" <WEBMASTER@R...>
<DIV></DIV>>Reply-To: "ASP Databases" <ASP_DATABASES@P...>
<DIV></DIV>>To: "ASP Databases" <ASP_DATABASES@P...>
<DIV></DIV>>Subject: [asp_databases] Re: access autonumber
<DIV></DIV>>Date: Fri, 20 Apr 2001 18:08:34 -0400
<DIV></DIV>>
<DIV></DIV>> Personally, I'd do this (which is less resource intensive on the
<DIV></DIV>>server):
<DIV></DIV>>
<DIV></DIV>>Set conConnection = CreateObject("ADODB.Connection")
<DIV></DIV>>Set rsRecordset = CreateObject("ADODB.Recordset")
<DIV></DIV>>
<DIV></DIV>>Private Function sNormal(sString)
<DIV></DIV>> sNormal = Replace(Request.Form(sString), "'", "''")
<DIV></DIV>>End Function
<DIV></DIV>>
<DIV></DIV>>conConnection = "DSN=DB2774A;UID=2774;PWD=156515"
<DIV></DIV>>conConnection.Execute "INSERT INTO customer " & _
<DIV></DIV>> "(last_name, first_name, email, company_name) VALUES (" & _
<DIV></DIV>> "'" & sNormal("last_name") & "', " & _
<DIV></DIV>> "'" & sNormal("first_name") & "', " & _
<DIV></DIV>> "'" & sNormal("email") & "', " & _
<DIV></DIV>> "'" & sNormal("company_name") & ")", , adCmdText + adExecuteNoRecords
<DIV></DIV>>
<DIV></DIV>>rsRecordset.Open "SELECT id FROM customer WHERE " & _
<DIV></DIV>> "last_name = '" & sNormal("last_name") & "' AND " & _
<DIV></DIV>> "first_name = '" & sNormal("first_name") & "' AND " & _
<DIV></DIV>> "company_name = '" & sNormal("company_name") & "'", conConnection, _
<DIV></DIV>> adOpenForwardOnly + adCmdText
<DIV></DIV>>
<DIV></DIV>>sID = rsRecordset("id")
<DIV></DIV>>
<DIV></DIV>>Of course you could just do SELECT MAX(id) FROM customer to return the last
<DIV></DIV>>ID entered if you don't think you'll have too many connections updating the
<DIV></DIV>>database at a time.
<DIV></DIV>>
<DIV></DIV>>- Chuck
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>----- Original Message -----
<DIV></DIV>>From: <CRYSTALIGHTENING@H...>
<DIV></DIV>>To: "ASP Databases" <ASP_DATABASES@P...>
<DIV></DIV>>Sent: Friday, April 20, 2001 10:21 PM
<DIV></DIV>>Subject: [asp_databases] access autonumber
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>> > Hello everyone :-)
<DIV></DIV>> > Why can't it find the autonumber in my db? I appreciate all your help.
<DIV></DIV>> >
<DIV></DIV>> > ADODB.Fields error '800a0cc1'
<DIV></DIV>> > ADO could not find the object in the collection corresponding to the name
<DIV></DIV>> > or ordinal reference requested by the application.
<DIV></DIV>> >
<DIV></DIV>> > /guestbook7.asp, line 40
<DIV></DIV>> >
<DIV></DIV>> > ------------------------------------------------------------------------
<DIV></DIV>> > asp code:
<DIV></DIV>> >
<DIV></DIV>> > <% @LANGUAGE = VBScript %>
<DIV></DIV>> > <% Option Explicit %>
<DIV></DIV>> >
<DIV></DIV>> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<DIV></DIV>> > <%
</DIV>> > Dim con,MessageDisplay, Rs
</DIV>> >
</DIV>> > Const adOpenForwardOnly = 0
</DIV>> > Const adOpenKeyset = 1
</DIV>> > Const adOpenDynamic = 2
</DIV>> > Const adOpenStatic = 3
</DIV>> > Const adLockReadOnly = 1
</DIV>> > Const adLockPessimistic = 2
</DIV>> > Const adLockOptimistic = 3
</DIV>> > Const adLockBatchOptimistic = 4
</DIV>> >
</DIV>> >
</DIV>> >
</DIV>> > if (Request.form("first_name") <>"" or Request.form("last_name") <>"" or
</DIV>> > Request.form("email") <>"") then
</DIV>> >
</DIV>> > ' Creating Connection Object and opening the database
</DIV>> > Set con = Server.CreateObject("ADODB.Connection")
</DIV>> > con.Open "DSN=DB2774A;UID=2774;PWD=156515"
</DIV>> >
</DIV>> > con.BeginTrans ' Start the Transaction this will need to be rolled back if
</DIV>> > there are errors anywhere.
</DIV>> >
</DIV>> > Set Rs = Server.CreateObject("ADODB.Recordset")
</DIV>> > Rs.ActiveConnection = con
</DIV>> > Rs.CursorType = adOpenKeyset
</DIV>> > Rs.LockType = adLockOptimistic
</DIV>> > Rs.Source = "customer" ' This is the Table Name
</DIV>> > Rs.Open
</DIV>> > Rs.AddNew
</DIV>> > RS("last_name") = Request.form("last_name")
</DIV>> > RS("first_name") = Request.form("first_name")
</DIV>> > RS("email") = Request.form("email")
</DIV>> > RS("company_name") = Request.form("company_name")
</DIV>> > RS.Update
</DIV>> >
</DIV>> > ' error occurs here
</DIV>> >
</DIV>> > Id = Rs("Id") ' This Returns the Id of the record that was just inserted.
</DIV>> >
</DIV>> > rs.Close
</DIV>> >
</DIV>> > On Error Resume Next
</DIV>> > rs.Source = "mailing_list_guestbook" ' Open the colors table so we can
</DIV>> > insert the data.
</DIV>> > rs.open
</DIV>> > Rs.AddNew
</DIV>> > Rs("id") = Id
</DIV>> > Rs("juiceplus") = Request.form("juiceplus")
</DIV>> > Rs("nadn") = Request.form("nadn")
</DIV>> > Rs("humor_digest") = Request.form("humor_digest")
</DIV>> >
</DIV>> > Rs.Update ' Write the data to the table.
</DIV>> > If con.Errors.Count > 0 Then
</DIV>> > On Error Goto 0
</DIV>> > con.RollBackTrans
</DIV>> > MessageDisplay = "Errors"
</DIV>> > Else
</DIV>> > con.CommitTrans
</DIV>> > MessageDisplay = "Your information has been recorded"
</DIV>> > End If
</DIV>> > On Error Goto 0
</DIV>> > On Error Goto 0
</DIV>> >
</DIV>> > ' Close out the open connection and RS
</DIV>> > Rs.Close
</DIV>> > Set Rs = Nothing
</DIV>> >
</DIV>> > con.Close
</DIV>> > Set con = Nothing
</DIV>> > Else
</DIV>> >
</DIV>> > Response.Write "Please enter a first, last name or email address and
</DIV>> > resubmit. Click the back button in your browser to get back to the
</DIV>> > Guestbook form. Thank you!"
</DIV>> > End If
</DIV>> > %>
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > <%= MessageDisplay %>
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > Crystal
<DIV></DIV>> >
</p></html>
Message #7 by "Charles Feduke" <webmaster@r...> on Sat, 28 Apr 2001 22:24:55 -0400
|
|
You'll definately need a connection variable or set the ActiveConnection
property of the recordset object. The connection variable tells IIS how
to find the database, so without it, you ASP script has no idea as to
what you're referring to. Make sure you have a ODBC connection setup on
the server then:
conConnection =3D Server.CreateObject("ADODB.Connection")
conConnection.Open "DSN=3Dthe_ODBC_name;UID=3Dusername;PWD=3Dpassword"
-or-
rsRecordset.ActiveConnection =3D
"DSN=3Dthe_ODBC_name;UID=3Dusername;PWD=3Dpassword"
I recommend the latter method if you are not going to use your
connection object to do anything with the database (i.e. updates,
sprocs, inserts, deletes, etc).
The adOpenForwardOnly and adCmdText are actually ADODB constant
variables. Providing those constants actually speeds up the processing
of the OLE DB driver (very slightly). You can get a listing of ADODB
constants from msdn.microsoft.com, but I'm sure something is out at
www.adopenstatic.com as well (MSDN makes it very difficult to find
them).
- Chuck
----- Original Message -----
From: crystal davis
To: ASP Databases
Sent: Thursday, April 26, 2001 3:22 PM
Subject: [asp_databases] Re: access autonumber
Chuck,
I want to thank you for your help. I have tried you code and I am
running into an error
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected
1.
/guestbook22.asp, line 27
-----------------------------------------
This line 27 down:::::::
rsRecordset.Open "SELECT id FROM customer WHERE " & _
"last_name =3D '" & sNormal("last_name") & "' AND " & _
"first_name =3D '" & sNormal("first_name") & "' AND " & _
"company_name =3D '" & sNormal("company_name") & "'" , conConnection
-------------------------------------------------------------------------
----
When I put in the variables adOpenForwardOnly + adCmdText. It gave me
another error that those two variables weren't defined. I assume they
are functions. Anyway when I take out the conConnection then I get an
error "invalid connection" Help! Oh! in my access db table customer I
have the following fields last_name, first_name, address, city, state,
country, telephone, cell_phone, email, company_name
Thanks for you help. Crystal
|
|
 |