Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Addnew????


Message #1 by "Todd Schuman" <todd_schuman@h...> on Mon, 21 Oct 2002 12:47:56
I am working on a project where I need to insert data into the database.  
I have been developing the project on my own computer running XP with IIS 
5.1.  I used the addnew method of adding to the database and everything 
was working great.  After uploading the files and database to the hosting 
server the addnew runs without an error but does nothing and no values 
are added to the database.  Has anyone run into a problem like this?  I 
really need some help here.

Thanks in advance!!!
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 22 Oct 2002 12:59:04 +1000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Todd Schuman" <todd_schuman@h...>
Subject: [access_asp] Addnew????


: I am working on a project where I need to insert data into the database.
: I have been developing the project on my own computer running XP with IIS
: 5.1.  I used the addnew method of adding to the database and everything
: was working great.  After uploading the files and database to the hosting
: server the addnew runs without an error but does nothing and no values
: are added to the database.  Has anyone run into a problem like this?  I
: really need some help here.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've seen many problems where things "don't work". Usually they are caused
by logical errors where your code is falling to somewhere other than what
you expect.

For example, you may have:

<%
If strUserName <> "" then
    ' Do AddNew Stuff Here
End If
%>

But what if strUserName *is* equal to ""? Your code doesn't handle that, you
get no errors, but you also get nothing in the database.

What I suggest you do,

a) is use "poor man's debugging", which involves putting Response.Write()
statements throughout the page, especially where you have conditional logic,
so you can see exactly what values your variables have, and also where the
code is falling to

b) put extra code in to handle all "unhandled" cases. This means that for
every "Select Case" construct you have a "Case Else" handler. For every
If...Then construct you have an "Else" handler, so that you can handle every
possible case. (Alternatively, you can also make the rest of your code more
robust in that each variable is tested for valid values before it is
used...)

Cheers
Ken

Message #3 by "Helga Y. Anagnostopoulos" <helga@k...> on Tue, 22 Oct 2002 10:15:06 +0200
Did you look at your security setup - who can add, bla..bla..bla

-----Original Message-----
From: Todd Schuman [mailto:todd_schuman@h...]
Sent: Monday, October 21, 2002 12:48
To: Access ASP
Subject: [access_asp] Addnew????


I am working on a project where I need to insert data into the database.  
I have been developing the project on my own computer running XP with IIS 
5.1.  I used the addnew method of adding to the database and everything 
was working great.  After uploading the files and database to the hosting 
server the addnew runs without an error but does nothing and no values 
are added to the database.  Has anyone run into a problem like this?  I 
really need some help here.

Thanks in advance!!!

Message #4 by "Alfred" <_Alfred@1...> on Tue, 22 Oct 2002 9:33:46 +0800
Todd Schuman,=C4=FA=BA=C3=A3=A1

=09can U placard Ur ASP code?

=3D=3D=3D=3D=3D=3D=3D 2002-10-21 12:47:00 =C4=FA=D4=DA=C0=B4=D0=C5=D6=D0=D0=B4=B5=C0=A3=BA=3D=3D=3D=3D=3D=3D=3D

>I am working on a project where I need to insert data into the
 database.  
>I have been developing the project on my own computer running XP
 with IIS 
>5.1.  I used the addnew method of adding to the database and
 everything 
>was working great.  After uploading the files and database to
 the hosting 
>server the addnew runs without an error but does nothing and no
 values 
>are added to the database.  Has anyone run into a problem like
 this?  I 
>really need some help here.
>
>Thanks in advance!!!
>.

=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D
=09=09=09

=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=D6=C2
=C0=F1=A3=A1
 
=09=09=09=09 
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1Alfred
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1_Alfred@1...
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12002-10-22




Message #5 by "Todd Schuman" <todd_schuman@h...> on Tue, 22 Oct 2002 18:45:10
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Todd Schuman" <todd_schuman@h...>
Subject: [access_asp] Addnew????


: I am working on a project where I need to insert data into the database.
: I have been developing the project on my own computer running XP with IIS
: 5.1.  I used the addnew method of adding to the database and everything
: was working great.  After uploading the files and database to the hosting
: server the addnew runs without an error but does nothing and no values
: are added to the database.  Has anyone run into a problem like this?  I
: really need some help here.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've seen many problems where things "don't work". Usually they are caused
by logical errors where your code is falling to somewhere other than what
you expect.

For example, you may have:

<%
If strUserName <> "" then
    ' Do AddNew Stuff Here
End If
%>

But what if strUserName *is* equal to ""? Your code doesn't handle that, 
you
get no errors, but you also get nothing in the database.

What I suggest you do,

a) is use "poor man's debugging", which involves putting Response.Write()
statements throughout the page, especially where you have conditional 
logic,
so you can see exactly what values your variables have, and also where the
code is falling to

b) put extra code in to handle all "unhandled" cases. This means that for
every "Select Case" construct you have a "Case Else" handler. For every
If...Then construct you have an "Else" handler, so that you can handle 
every
possible case. (Alternatively, you can also make the rest of your code more
robust in that each variable is tested for valid values before it is
used...)

Cheers
Ken

Ken,

I dont think it is a logical error because the page that is called doesn't 
have any if/else or case statements.  It simple opens the DB connection, 
creates a recordset, adds the new fields, updates, and closes the 
recordset and conn.  

The thing that I can't figurte out is why did it work fine on my PC 
running IIS and it runs without error on the webserver but doesnt add 
anything.  Is there a possibilty that not all servers allow the addnew 
feature and that I must use an INSERT SQL statement instead???

Thanks,
Todd
Message #6 by "Ken Schaefer" <ken@a...> on Wed, 23 Oct 2002 10:11:27 +1000
Todd,

Please post the code you are using. If .AddNew can not complete what it
needs to do, it should throw an exception.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Todd Schuman" <todd_schuman@h...>
Subject: [access_asp] Re: Addnew????


: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: "Todd Schuman" <todd_schuman@h...>
: Subject: [access_asp] Addnew????
:
:
: : I am working on a project where I need to insert data into the database.
: : I have been developing the project on my own computer running XP with
IIS
: : 5.1.  I used the addnew method of adding to the database and everything
: : was working great.  After uploading the files and database to the
hosting
: : server the addnew runs without an error but does nothing and no values
: : are added to the database.  Has anyone run into a problem like this?  I
: : really need some help here.
:
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:
: I've seen many problems where things "don't work". Usually they are caused
: by logical errors where your code is falling to somewhere other than what
: you expect.
:
: For example, you may have:
:
: <%
: If strUserName <> "" then
:     ' Do AddNew Stuff Here
: End If
: %>
:
: But what if strUserName *is* equal to ""? Your code doesn't handle that,
: you
: get no errors, but you also get nothing in the database.
:
: What I suggest you do,
:
: a) is use "poor man's debugging", which involves putting Response.Write()
: statements throughout the page, especially where you have conditional
: logic,
: so you can see exactly what values your variables have, and also where the
: code is falling to
:
: b) put extra code in to handle all "unhandled" cases. This means that for
: every "Select Case" construct you have a "Case Else" handler. For every
: If...Then construct you have an "Else" handler, so that you can handle
: every
: possible case. (Alternatively, you can also make the rest of your code
more
: robust in that each variable is tested for valid values before it is
: used...)
:
: Cheers
: Ken
:
: Ken,
:
: I dont think it is a logical error because the page that is called doesn't
: have any if/else or case statements.  It simple opens the DB connection,
: creates a recordset, adds the new fields, updates, and closes the
: recordset and conn.
:
: The thing that I can't figurte out is why did it work fine on my PC
: running IIS and it runs without error on the webserver but doesnt add
: anything.  Is there a possibilty that not all servers allow the addnew
: feature and that I must use an INSERT SQL statement instead???
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.

Message #7 by "Todd Schuman" <todd_schuman@h...> on Fri, 25 Oct 2002 02:43:08
Ken,

Here is the code that I have:

<%
Dim connStr
connStr ="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\inetpub\wwwroot\corcom\Webbase.mdb;"
		
'Establish Connection
Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")	
Conn.Open connStr

dim str
dim objRS
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open "ADDRESS_BOOK", Conn, adOpenDynamic, adLockPessimistic
str = request.form("LastName") &", " &request.form("FirstName")
objRS.AddNew
objRS.fields("ADDR_EMP_ID")=Session("ID")
objRS.fields("ADDR_LOOKUP")=UCase(str)
objRS.fields("ADDR_GROUP")=Request.Form("Group")
objRS.fields("ADDR_FIRST")=Trim(Request.Form("FirstName"))
objRS.fields("ADDR_LAST")=Trim(Request.Form("LastName"))
objRS.fields("ADDR_COMP")=Trim(Request.Form("Company"))
objRS.fields("ADDR_ADDR1")=Request.Form("Addr_1")
objRS.fields("ADDR_ADDR2")=Request.Form("Addr_2")
objRS.fields("ADDR_ADDR3")=Request.Form("Addr_3")
objRS.fields("ADDR_CITY")=Trim(Request.Form("City"))
objRS.fields("ADDR_ST")=Request.Form("State")
objRS.fields("ADDR_ZIP")=Trim(Request.Form("Zip"))
objRS.fields("ADDR_COUNTRY")=Trim(Request.Form("Country"))
objRS.fields("ADDR_PHONE")=Trim(Request.Form("Phone"))
objRS.fields("ADDR_EMAIL")=Trim(Request.Form("Email"))
objRS.Update

'Done, Now close
'objRS.Close	

if request.form("action") = "add" then		
	response.redirect "address.asp"
elseif request.form("action") = "finish" then		
	response.redirect "addressintro.asp"
end if
%>

There is no if or case statemnets until the end and that only directs the 
user to the appropriate page.  I am dumbfounded as to why this would work 
on my computer and not on the webserver.  Any ideas?  I am dying over 
here!
Message #8 by "Ken Schaefer" <ken@a...> on Fri, 25 Oct 2002 12:37:46 +1000
Couple of quick questions:

a) Is this all the code? There is nothing else, eg no include files? No "on
error resume next"? No
<% @Language=VBScript%>?

b) What happens if you replace:
: 'Done, Now close
: 'objRS.Close
:
: if request.form("action") = "add" then
: response.redirect "address.asp"
: elseif request.form("action") = "finish" then
: response.redirect "addressintro.asp"
: end if

with:

<%
' The following are *important*
' You should be doing this before you
' redirect, to return the connection to the pool!
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing

Response.Write("Done!")
%>

c) If still not working, what happens if you replace the code:

objRS.fields("ADDR_EMP_ID")=...

with

objRS.Fields("ADDR_EMP_ID").Value=...

(and similarly for the other fields)

d) Also, how do you know that the record isn't being added? Did you download
the database to have a look inside?

e) What is the primary key field for this table? And what type is it? (I'm
going to suggest some more debugging based on what this field is)

f) With the Jet Provider, you aren't actually gettting the record/cursor
types you are asking for. Check out:
www.adopenstatic.com/faq/jetcursortypes.asp

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Todd Schuman" <todd_schuman@h...>
Subject: [access_asp] Re: Addnew????


: Ken,
:
: Here is the code that I have:
:
: <%
: Dim connStr
: connStr ="Provider=Microsoft.Jet.OLEDB.4.0;Data
: Source=C:\inetpub\wwwroot\corcom\Webbase.mdb;"
:
: 'Establish Connection
: Dim Conn
: Set Conn = Server.CreateObject("ADODB.Connection")
: Conn.Open connStr
:
: dim str
: dim objRS
: Set objRS=Server.CreateObject("ADODB.Recordset")
: objRS.Open "ADDRESS_BOOK", Conn, adOpenDynamic, adLockPessimistic
: str = request.form("LastName") &", " &request.form("FirstName")
: objRS.AddNew
: objRS.fields("ADDR_EMP_ID")=Session("ID")
: objRS.fields("ADDR_LOOKUP")=UCase(str)
: objRS.fields("ADDR_GROUP")=Request.Form("Group")
: objRS.fields("ADDR_FIRST")=Trim(Request.Form("FirstName"))
: objRS.fields("ADDR_LAST")=Trim(Request.Form("LastName"))
: objRS.fields("ADDR_COMP")=Trim(Request.Form("Company"))
: objRS.fields("ADDR_ADDR1")=Request.Form("Addr_1")
: objRS.fields("ADDR_ADDR2")=Request.Form("Addr_2")
: objRS.fields("ADDR_ADDR3")=Request.Form("Addr_3")
: objRS.fields("ADDR_CITY")=Trim(Request.Form("City"))
: objRS.fields("ADDR_ST")=Request.Form("State")
: objRS.fields("ADDR_ZIP")=Trim(Request.Form("Zip"))
: objRS.fields("ADDR_COUNTRY")=Trim(Request.Form("Country"))
: objRS.fields("ADDR_PHONE")=Trim(Request.Form("Phone"))
: objRS.fields("ADDR_EMAIL")=Trim(Request.Form("Email"))
: objRS.Update
:
: 'Done, Now close
: 'objRS.Close
:
: if request.form("action") = "add" then
: response.redirect "address.asp"
: elseif request.form("action") = "finish" then
: response.redirect "addressintro.asp"
: end if
: %>
:
: There is no if or case statemnets until the end and that only directs the
: user to the appropriate page.  I am dumbfounded as to why this would work
: on my computer and not on the webserver.  Any ideas?  I am dying over
: here!

Message #9 by "Todd Schuman" <todd_schuman@h...> on Fri, 25 Oct 2002 17:13:52
> Couple of quick questions:

a) Is this all the code? There is nothing else, eg no include files? No "on
error resume next"? No
<% @Language=VBScript%>?
I had the connection string in an include file and adovbs.inc as well but 
pasted them in to show them

b) What happens if you replace:
: 'Done, Now close
: 'objRS.Close
:
: if request.form("action") = "add" then
: response.redirect "address.asp"
: elseif request.form("action") = "finish" then
: response.redirect "addressintro.asp"
: end if

with:

<%
' The following are *important*
' You should be doing this before you
' redirect, to return the connection to the pool!
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing

Response.Write("Done!")
%>

I will try closing the Connection before I redirect
c) If still not working, what happens if you replace the code:

objRS.fields("ADDR_EMP_ID")=...

with

objRS.Fields("ADDR_EMP_ID").Value=...

(and similarly for the other fields)

I will also try this!

d) Also, how do you know that the record isn't being added? Did you 
download
the database to have a look inside?

The way i know is that there is a page which pulls up all the names with a 
select statement.  I had manually entered a few names which all appear but 
the ones i add while on the web server dont appear.

e) What is the primary key field for this table? And what type is it? (I'm
going to suggest some more debugging based on what this field is)

I am going to have to check on that once i get home

f) With the Jet Provider, you aren't actually gettting the record/cursor
types you are asking for. Check out:
www.adopenstatic.com/faq/jetcursortypes.asp

I will check this out!

Cheers
Ken


Thanks for your help Ken, I will try some of your suggestions as soon as I 
get home.

Todd
Message #10 by "Todd Schuman" <todd_schuman@h...> on Sat, 26 Oct 2002 01:48:52
Ken,

here is my updated code..still doesnt add anything:

<!--#include file="Connect.inc"-->
<%
	dim str
	dim objRS
	Set objRS=Server.CreateObject("ADODB.Recordset")
	objRS.Open "ADDRESS_BOOK", Conn, adOpenKeyset, adLockOptimistic
	str = request.form("LastName") &", " &request.form("FirstName")
	objRS.AddNew
	objRS.fields("ADDR_EMP_ID").Value=Session("ID")
	objRS.fields("ADDR_LOOKUP").Value=UCase(str)
	objRS.fields("ADDR_GROUP").Value=Request.Form("Group")
	objRS.fields("ADDR_FIRST").Value=Trim(Request.Form("FirstName"))
	objRS.fields("ADDR_LAST").Value=Trim(Request.Form("LastName"))
	objRS.fields("ADDR_COMP").Value=Trim(Request.Form("Company"))
	objRS.fields("ADDR_ADDR1").Value=Request.Form("Addr_1")
	objRS.fields("ADDR_ADDR2").Value=Request.Form("Addr_2")
	objRS.fields("ADDR_ADDR3").Value=Request.Form("Addr_3")
	objRS.fields("ADDR_CITY").Value=Trim(Request.Form("City"))
	objRS.fields("ADDR_ST").Value=Request.Form("State")
	objRS.fields("ADDR_ZIP").Value=Trim(Request.Form("Zip"))
	objRS.fields("ADDR_COUNTRY").Value=Trim(Request.Form("Country"))
	objRS.fields("ADDR_PHONE").Value=Trim(Request.Form("Phone"))
	objRS.fields("ADDR_EMAIL").Value=Trim(Request.Form("Email"))
	objRS.Update
	
	'Done, Now close
	objRS.Close	
	Set objRS=nothing
	
	Conn.Close
	Set Conn=nothing
	
	Response.write("done!")
	'response.end
	if request.form("action") = "add" then		
		response.redirect "address.asp"
	elseif request.form("action") = "finish" then		
		response.redirect "addressintro.asp"
	end if
	
%>

As for the primary key there isnt one in this table.  The users email 
address is stored in a session variable once they log in and this is used 
to add and select the appriopriate data.

Any ideas???
Message #11 by "Ken Schaefer" <ken@a...> on Sat, 26 Oct 2002 23:23:31 +1000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Todd Schuman" <todd_schuman@h...>
Subject: [access_asp] Re: Addnew????


: d) Also, how do you know that the record isn't being added? Did you
: download the database to have a look inside?
:
: The way i know is that there is a page which pulls up all the names with a
: select statement.  I had manually entered a few names which all appear but
: the ones i add while on the web server dont appear.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is getting kinda complexing! Usually an error would be thrown (and a
nasty error message displayed on the screen if the code barfs anywhere).
Sorry to bother you more, but you download your database and take a look
inside (on your own machine). Possibly the page that 'lists' the records is
being cached (either by your browser, or by the server), which may explain
why you're not seeing new records.

Also, look inside the "include" file that you have:
<!--#include file="Connect.inc"-->
and make sure there is no "On Error Resume Next" anywhere. This will stop
errors being thrown - instead ASP will continue on without generating an
error.

Lastly, add a primary key to the table - you must have a primary key on each
table in your database if you ever want to get a subset of the data out (or
update any record) etc...It may also generate errors if you try to add data.
(That said, in all cases you should see an error message though, not the
situation you seem to have, where there appears to be no error at all!)

Cheers
Ken

Cheers
Ken

Message #12 by "Todd Schuman" <todd_schuman@h...> on Sat, 26 Oct 2002 17:44:48
Aha!  I did have a on Error Resume Next in the include file.  I commented 
it out and am now getting an error message.

Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.

I have checked the properties of the database and read only has not been 
checked.  I believe it might have something to do with the folder on the 
server.  I do not have regular ftp access to this server and must use 
PCAnywhere to connect and transfer files.  How can i exzecute a CHMOD 
with out being able to type in the command.  Do i need to make some kind 
of script file?
Message #13 by "Charles Mabbott" <aa8vs@m...> on Sat, 26 Oct 2002 15:27:55 -0400
Just some comments...


>From: "Todd Schuman" <todd_schuman@h...>
>Reply-To: "Access ASP" <access_asp@p...>
>To: "Access ASP" <access_asp@p...>
>Subject: [access_asp] Re: Addnew????
>Date: Sat, 26 Oct 2002 17:44:48
>
>Aha!  I did have a on Error Resume Next in the include file.  I commented
>it out and am now getting an error message.
>
>Microsoft JET Database Engine (0x80040E09)
>Cannot update. Database or object is read-only.
>
>I have checked the properties of the database and read only has not been
>checked.

Is the server not in your house?  If so you need to check with sys admin who 
has full access to server.
Database may be OK, but directory needs to be checked.

I believe it might have something to do with the folder on the
>server.  I do not have regular ftp access to this server and must use
>PCAnywhere to connect and transfer files.  How can i execute a CHMOD

CHMOD is a UNIX command, what system is the
Database on?  If the server does not belong to you, again you will have to 
check with sys admin.


>with out being able to type in the command.  Do i need to make some kind of 
>script file?

You may not be able to until given privilege to do so.
>---

Regards,
Chuck

"Whoever said the pen is mightier than the
sword obviously never encountered automatic
weapons."

http://68.43.100.7:81/aa8vs



_________________________________________________________________
Choose an Internet access plan right for you -- try MSN! 
http://resourcecenter.msn.com/access/plans/default.asp

Message #14 by "Todd Schuman" <todd_schuman@h...> on Sun, 27 Oct 2002 21:02:23
At last.  Everything is working perfectly now.  I just needed to fix the 
permissions on the folder.  Thanks Chuck and especially Ken.  I am now 
considering naming my first child Ken.  

Thanks again everyone.

Todd
Message #15 by "Eduardo Porcel" <eporcel@o...> on Wed, 30 Oct 2002 16:48:03
Hello:

I donīt know but I can not add a ne record to a table. Any help.

Here is my code

Thanks in Advance

<%@ LANGUAGE = VBScript %>
<%  Option Explicit %>
<%  Response.Expires= -1 %>
<!--#include file="ADOVBS.INC"-->
<%
Dim con, strConn
Set con= Server.CreateObject("ADODB.Connection")

strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; "
strConn = strConn & "DBQ=" & Server.Mappath("cursosbd.mdb")
con.Open strConn

Dim SQL, rec
set rec = server.createobject("adodb.recordset")
SQL = "select * from CveZona"
set rec = con.execute(SQL)

rec.AddNew
rec("Empresa")=Request.Form("CustEnterprise")
rec("mail")=Request.Form("CustMail")
rec("Contacto")=Request.Form("CustName")
rec.Update
rec.MoveFirst   
Message #16 by "Eduardo Porcel" <eporcel@o...> on Wed, 30 Oct 2002 16:52:33
Help me on this, I want to add records but itīs not working

Any help??

Thanks in advance

<%@ LANGUAGE = VBScript %>
<%  Option Explicit %>
<%  Response.Expires= -1 %>
<!--#include file="ADOVBS.INC"-->
<%
Dim con, strConn
Set con= Server.CreateObject("ADODB.Connection")

strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; "
strConn = strConn & "DBQ=" & Server.Mappath("cursosbd.mdb")
con.Open strConn

Dim SQL, rec
set rec = server.createobject("adodb.recordset")
SQL = "select * from CveZona"
set rec = con.execute(SQL)

rec.AddNew
rec("Empresa")=Request.Form("CustEnterprise")
rec("mail")=Request.Form("CustMail")
rec("Contacto")=Request.Form("CustName")
rec.Update
rec.MoveFirst   
Message #17 by "Larry Woods" <larry@l...> on Wed, 30 Oct 2002 10:26:47 -0700
You CAN'T update a recordset created by either a Connection or a
Command.  Open a Recordset object instead.  Also, you cannot take
the default parameters of the recordset.  Set as follows:

rec.CursorType=3
rec.LockType=3
rec.Open SQL,con
rec.AddNew
.....etc.



Larry Woods


> -----Original Message-----
> From: Eduardo Porcel [mailto:eporcel@o...]
> Sent: Wednesday, October 30, 2002 4:48 PM
> To: Access ASP
> Subject: [access_asp] AddNew
>
>
> Hello:
>
> I donīt know but I can not add a ne record to a table.
> Any help.
>
> Here is my code
>
> Thanks in Advance
>
> <%@ LANGUAGE = VBScript %>
> <%  Option Explicit %>
> <%  Response.Expires= -1 %>
> <!--#include file="ADOVBS.INC"-->
> <%
> Dim con, strConn
> Set con= Server.CreateObject("ADODB.Connection")
>
> strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; "
> strConn = strConn & "DBQ=" & Server.Mappath("cursosbd.mdb")
> con.Open strConn
>
> Dim SQL, rec
> set rec = server.createobject("adodb.recordset")
> SQL = "select * from CveZona"
> set rec = con.execute(SQL)
>
> rec.AddNew
> rec("Empresa")=Request.Form("CustEnterprise")
> rec("mail")=Request.Form("CustMail")
> rec("Contacto")=Request.Form("CustName")
> rec.Update
> rec.MoveFirst
>


  Return to Index