|
 |
asp_databases thread: AddNew procedure in The ASP Databases Book
Message #1 by "mamoon" <elahme2@h...> on Tue, 15 Aug 2000 14:52:8
|
|
hi,
I'm trying to use the AddNew command from the page 304, chapter 9. I'm
used to using SQL statements to do my insertions into a database but this
procedure looks neat and i will like to use it. i'm using SQL 7.0 and
working on win 2000 server. this is the error that i get :
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored
procedure 'AddNew'.
/development-elahi/test1.asp, line 25
this is the code :
<html>
<head>
<title>Untitled</title>
</head>
<body>
<h2> Inserted the values into the database ! </h2>
<%
dim my_conn
dim varfirstName, varlastname
set my_conn=Server.CreateObject("ADODB.Connection")
my_conn.open application("dbconnect")
my_conn.AddNew
my_conn.Fields("First_name")=Request.Form("firstname")
my_conn.Fields("Last_name")=Request.Form("lastname")
my_conn.Update
response.write "<P> A new Student has been added using the following values
: " _
& "<P> First name: " & my_conn.Fields("First_name") _
& "<P> Last name: " & my_conn.Fields("Last_name") & "</P>"
my_conn.Close
set my_conn=nothing
%>
<a href="javascript:history.back()">Return</a>
</body>
</html>
thank you,
email: mamoon.elahi@o...
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 16 Aug 2000 11:44:17 +1000
|
|
.AddNew is not a method of the Connection Object - it is a method of the
RecordSet object.
You need to create a Recordset, and then call the .AddNew method:
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "table1", objConn, adOpenForwardOnly, adLockOptimistic,
adCmdTableDirect
objRS.AddNew
...
objRS.Update
objRS.close
Set objRS = nothing
HTH
Cheers
Ken
----- Original Message -----
From: "mamoon"
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, August 15, 2000 2:00 PM
Subject: [asp_databases] AddNew procedure in The ASP Databases Book
> hi,
> I'm trying to use the AddNew command from the page 304, chapter 9. I'm
> used to using SQL statements to do my insertions into a database but this
> procedure looks neat and i will like to use it. i'm using SQL 7.0 and
> working on win 2000 server. this is the error that i get :
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
> [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored
> procedure 'AddNew'.
>
> /development-elahi/test1.asp, line 25
>
> this is the code :
>
> <html>
> <head>
> <title>Untitled</title>
> </head>
>
> <body>
>
> <h2> Inserted the values into the database ! </h2>
> <%
> dim my_conn
> dim varfirstName, varlastname
>
> set my_conn=Server.CreateObject("ADODB.Connection")
> my_conn.open application("dbconnect")
>
> my_conn.AddNew
> my_conn.Fields("First_name")=Request.Form("firstname")
> my_conn.Fields("Last_name")=Request.Form("lastname")
> my_conn.Update
> response.write "<P> A new Student has been added using the following
values
> : " _
> & "<P> First name: " & my_conn.Fields("First_name") _
> & "<P> Last name: " & my_conn.Fields("Last_name") & "</P>"
> my_conn.Close
> set my_conn=nothing
> %>
> <a href="javascript:history.back()">Return</a>
>
> </body>
> </html>
>
> thank you,
> email: mamoon.elahi@o...
>
|
|
 |