IIS ASP - brand new newbie: This simple code does not even work. please help.

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > June 2004 > brand new newbie: This simple code does not even work. please help.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author brand new newbie: This simple code does not even work. please help.
Jacques Koorts

2004-06-01, 11:53 pm

Hi,

I have a Db, c:\events.mdb with a table "comments", with the first 2 fields
as strings and the 3rd as a number. The html code below does not work and
I'm really feeling frustrated now. I get the error:

The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot
be displayed.

Can someone please help me? PS. I've inclosed the 67 in quotes as well and
still same error.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
</head>

<body>
<%
dim SetConn
Set SetConn = Server.CreateObject("ADODB.Connection")
SetConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\events.mdb;"
SetConn.Execute("INSERT INTO comments VALUES 'string1', 'string2', 67")
%>

</body>
</html>


Aaron [SQL Server MVP]

2004-06-01, 11:53 pm

(a) you need to determine the real error (see http://www.aspfaq.com/2109 )

(b) why is your database in c:\ ? Put it in the same folder as the ASP
page, and then use

SetConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
server.Mappath("events.mdb")

Why SetConn? How about just conn?

--
http://www.aspfaq.com/
(Reverse address to reply.)




"Jacques Koorts" <jkoorts@myrealbox.com> wrote in message
news:10bq96b39kslk42@corp.supernews.com...
> Hi,
>
> I have a Db, c:\events.mdb with a table "comments", with the first 2
> fields
> as strings and the 3rd as a number. The html code below does not work and
> I'm really feeling frustrated now. I get the error:
>
> The page cannot be displayed
> There is a problem with the page you are trying to reach and it
> cannot
> be displayed.
>
> Can someone please help me? PS. I've inclosed the 67 in quotes as well and
> still same error.
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
> <html>
> <head>
> <title></title>
> </head>
>
> <body>
> <%
> dim SetConn
> Set SetConn = Server.CreateObject("ADODB.Connection")
> SetConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=c:\events.mdb;"
> SetConn.Execute("INSERT INTO comments VALUES 'string1', 'string2', 67")
> %>
>
> </body>
> </html>
>
>



Roland Hall

2004-06-01, 11:53 pm

"Jacques Koorts" wrote in message news:10bq96b39kslk42@corp.supernews.com...
: I have a Db, c:\events.mdb with a table "comments", with the first 2
fields
: as strings and the 3rd as a number. The html code below does not work and
: I'm really feeling frustrated now. I get the error:
:
: The page cannot be displayed
: There is a problem with the page you are trying to reach and it
cannot
: be displayed.

Probably because the current error is a permissions issue.

1. You shouldn't put your database in the root of your drive since the
anonymous user will need change access rights.
2. How are you trying to access this page? http://localhost/myinsert.asp or
similar?

: Can someone please help me? PS. I've inclosed the 67 in quotes as well and
: still same error.
:
: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
: "http://www.w3.org/TR/html4/strict.dtd">
:
: <html>
: <head>
: <title></title>
: </head>
:
: <body>
: <%
: dim SetConn
: Set SetConn = Server.CreateObject("ADODB.Connection")
: SetConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
: Source=c:\events.mdb;"
: SetConn.Execute("INSERT INTO comments VALUES 'string1', 'string2',
67")
: %>
:
: </body>
: </html>

<%
dim conn, strConn
set conn = CreateObject("ADODB.Connection")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\events.mdb;"
strSQL = "INSERT INTO comments VALUES ('string1', 'string2', '67')"
conn.open strConn
conn.execute(strSQL)
conn.close
set conn = nothing
%>

However, preferably, in this case for performance reasons...

strSQL = "INSERT INTO comments VALUES ('string1', 'string2', '67'), ,
adExecuteNoRecords + adCmdText"

http://www.asp101.com/tips/index.asp?id=85
http://www.a1vbcode.com/vbtip.asp?ID=131

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Patrice

2004-06-02, 7:53 am

Additionaly the correct syntax for the SQL is :
INSERT INTO Comments VALUES ('String1','string2',67)

The top thing to do is to display the real error message (see previous posts
in this thread)

Patrice

"Jacques Koorts" <jkoorts@myrealbox.com> a écrit dans le message de
news:10bq96b39kslk42@corp.supernews.com...
> Hi,
>
> I have a Db, c:\events.mdb with a table "comments", with the first 2

fields
> as strings and the 3rd as a number. The html code below does not work and
> I'm really feeling frustrated now. I get the error:
>
> The page cannot be displayed
> There is a problem with the page you are trying to reach and it

cannot
> be displayed.
>
> Can someone please help me? PS. I've inclosed the 67 in quotes as well and
> still same error.
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
> <html>
> <head>
> <title></title>
> </head>
>
> <body>
> <%
> dim SetConn
> Set SetConn = Server.CreateObject("ADODB.Connection")
> SetConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=c:\events.mdb;"
> SetConn.Execute("INSERT INTO comments VALUES 'string1', 'string2',

67")
> %>
>
> </body>
> </html>
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com