Forum Moderators: mack

Message Too Old, No Replies

What's wrong with this ASP code?

I bet it's something simple.

         

chris_f

1:53 pm on Sep 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok,

Any help is appreciated. I know ASP.net but never actually learned ASP. Due to the server the site is going to be hosted on I cannot use ASP.net. I am trying a simple access database insert. The database has a table called PageContent. It has two fields:

Heading = Text
Content = Memo

Here is the code I am using:

<%@ LANGUAGE="VBScript" %>
<HTML>
<HEAD>
<TITLE>DATABASE INSERT</TITLE>
</HEAD>
<BODY>

<% If request("REQUEST_METHOD") <> "POST" then %>

<h1>Leave message</h1>
<FORM ACTION="addition.asp" METHOD="post">
<TABLE>

<TR><TH>Heading: <TD><INPUT NAME="MessageHeading" SIZE=50>
<TR><TH>Content: <TD><INPUT NAME="MessageContent" SIZE=50>
</TABLE>
<INPUT TYPE="submit" VALUE="SUBMIT">
<INPUT TYPE="reset" VALUE="RESET">
</FORM>

<% Else
' Data Entry
Set Cnn = Server.CreateObject("ADODB.Connection")
Set CnnRS = Server.CreateObject("ADODB.Recordset")

Cnn.Open "123"
CnnRS.Open "SELECT * FROM PageContent", _
Cnn, adOpenDynamic, adLockOptimistic, adCmdText

CnnRS.AddNew
CnnRS("Heading") = request("MessageHeading")
CnnRS("Content") = request("MessageContent")
CnnRS.Update %>

CnnRS.Close
Cnn.Close
Set CnnRS = Nothing
Set Cnn = Nothing

<h1>Thank You</h1>

<% End If %>

<hr>
<a href="default.asp">Back</a>

</BODY>
</HTML>

Here is the error message I am getting

ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/sites/123/addition.asp, line 27

Any help is greatly appreciated.

Thanks.
Chris.

olias

2:12 pm on Sep 22, 2002 (gmt 0)

10+ Year Member



I think you need to declare the constants adOpenDynamic, adLockOptimistic and adCmdText.

Try the following lines,
Const AdOpenDynamic = 1
Const adCmdText = 1
Const adLockOptimistic = 3

Alternatively you might want to just include adovbs.inc, try a search on it there is lots of info out there.

BlobFisk

2:16 pm on Sep 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ASP101.com have a good article on the adovbs.inc. You can read it here [asp101.com].

chris_f

2:17 pm on Sep 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you Olias,

I forgot to include the adovbs.inc. It works great now.

Thanks.
Chris.