Groups | Blog | Home
all groups > inetserver asp db > november 2004 >

inetserver asp db : weird error, don't know why


Bob Barrows [MVP]
11/24/2004 9:23:03 AM
[quoted text, click to view]

While AddNew and Update may be efficient in VB, they are very inefficient in
ASP. You should be using saved parameter queries to do your inserts and
updates. See:


http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&selm=eHYxOyvaDHA.4020%40tk2msftngp13.phx.gbl


http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&selm=ukS%246S%247CHA.2464%40TK2MSFTNGP11.phx.gbl

http://www.google.com/groups?selm=eETTdnvFDHA.1660%40TK2MSFTNGP10.phx.gbl&oe=UTF-8&output=gplain

[quoted text, click to view]

What occurs??? We're not looking over your shoulder. You need to tell us
what your symptoms are if we are to have any chance at all of diagnosing
your problem.

As a guess, I suspect you are experiencing permissions issues. Your IUSR
account (Internet Guest Account) requires read/write permissions on the
folder containing your database (not just the mdb file - the entire folder).
See
http://www.aspfaq.com/show.asp?id=2009
http://www.aspfaq.com/show.asp?id=2062

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

JohnDpatriot
11/24/2004 10:31:07 AM
[quoted text, click to view]
Bob,

Would it be equally innefficient to write the adds/updates as SQL and
execute them ?

ie.

STRSQL = "INSERT INTO TBLREQUEST (strRemarks) USING ('blablablabla...')"
Set objRS = strConn.Execute(STRSQL)




Philmans
11/24/2004 10:39:55 AM
Hi all,

What's wrong with the code below?
Everything is working fine except the Addnew and the Update lines?

All names and paths are correct, when i just read the database there's no
problem, it occurs when i want to add/update something.
I checked the same code back in Visual Basic and there no problem at all.

Could somebody please help me out?

Code listing:

<%
dim sfirstname
dim slastname


sfirstname = request.form("firstname")
slastname = request.form("lastname")

dim cnReq
dim strConn
dim rsReq
dim strSQL

Set cnReq = Server.CreateObject("ADODB.Connection")
strConn = "Provider=MICROSOFT.JET.OLEDB.4.0; " & "DATA SOURCE=" &
Server.MapPath("databases/requests.mdb") & ";"

cnReq.open strConn

Set rsReq = Server.CreateObject("ADODB.Recordset")
rsReq.CursorType = 2
rsReq.LockType = 3

strSQL = "SELECT top 1 * FROM tblRequest;"

rsReq.Open strSQL, cnReq

if rsReq.eof then
rsReq.addnew

rsReq.fields("strRemarks")="blablablabla..."
rsReq.fields("dtmDate")=now
rsReq.update
else
rsReq.fields("dtmDate")=now
rsReq.update
end if

rsReq.close

cnReq.close
set cnReq = nothing

%>

Bob Barrows [MVP]
11/24/2004 11:20:52 AM
[quoted text, click to view]

??Why would you open a recordset on a query that does not return records??
If you're going to do this, then skip the recordset:

cnReq.Execute strSQL,,129

The 129 tells ADO not to create a recordset because the query you are
executing does not return records.


I cover the problems with using dynamic sql in at least one of the links I
provided in my earlier reply. Using dynamic sql to create your update/insert
statements will be more efficient than using a recordset, but less
efficient, and less secure, than using a saved parameter query.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

JohnDpatriot
11/24/2004 11:45:24 AM
[quoted text, click to view]

I am using an advantage server to connect to a foxpro database being
hosted on a novell 5.1 server. Unfortunately saved parameter queries
are not an option for me, but I like the idea of the ,,129. I will
implement it.

Bob Barrows [MVP]
11/24/2004 1:39:35 PM
[quoted text, click to view]

Foxpro doesn't support stored procedures? Too bad.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Bob Barrows [MVP]
11/25/2004 7:48:27 AM
[quoted text, click to view]

If you are getting general 500 error messages, then you need to turn off
Friendly Error Messages in your browser so you can find out what actually is
happening.

http://www.aspfaq.com/show.asp?id=2109

[quoted text, click to view]

In addition to the above, it's time for some basic debugging. I assume
you've tested your saved query in Access so you know it works when proper
parameter values are provided. That allows us to concentrate on your ASP
code.

[quoted text, click to view]

First of all, verify that this data has been properly passed:

Response.write "strFirstName contains """ & strFirstName & """<BR>"
Response.write "strLastName contains """ & strLastName & """<BR>"

[quoted text, click to view]

Now do some error-trapping:

On Error Resume Next

[quoted text, click to view]

If err <> 0 then
Response.Write "An error occurred when attempting to open cnReq:<BR>"
Response.Write err.Number & ": " & err.Description
set cnReq = Nothing
Response.End
end if

[quoted text, click to view]

If err <> 0 then
Response.Write "An error occurred when attempting to add data:<BR>"
Response.Write err.Number & ": " & err.Description
cnReq.close: set cnReq = Nothing
Response.End
end if

[quoted text, click to view]

Don't forget to close and destroy your connection:

cnReq.close: set cnReq = Nothing


Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Philmans
11/25/2004 9:03:11 AM
Hi Bob,

i've did try your solutions and none of the above seems to be working out
ok.

I'm still getting some general 500 error code when the cnReq connection
tries to insert values into the table by passing params through a saved
query.

You talked about permissions but they're all fine. I have several other
Access-databases as well running and, strange thing, they all accept
the update and addnew and insert into commands, none of them is returning a
error.

I'm just tripping, it's driving me nuts!

<%
dim strConn
dim strSQL
dim strFirstName
dim strLastName

strFirstName = request.form("firstname")
strLastName = request.form("lastname")

Set cnReq = Server.CreateObject("ADODB.Connection")
strConn = "Provider=MICROSOFT.JET.OLEDB.4.0; " & "DATA SOURCE=" &
Server.MapPath("databases/requests.mdb") & ";"

cnReq.open strConn

cnReq.qryAddApp strFirstName,strLastName

%>

cao

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> schreef in bericht
news:eHSkzTl0EHA.1188@tk2msftngp13.phx.gbl...
[quoted text, click to view]

Bob Barrows [MVP]
11/25/2004 4:59:15 PM
[quoted text, click to view]

You don't use the 129 in your Connection open statement. It's meant to be
used when executing a query.

cnReq.Execute strSQL,,129

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Philmans
11/25/2004 9:23:43 PM
I turned off Friendly Error Messages and now i have this error:


Microsoft JET Database Engine error '80040e4d'

Cannot start your application. The workgroup information file is missing or
opened exclusively by another user.

/processrequest.asp, line 9



code below:

<%

dim strConn
dim cnReq

strConn = "Provider=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" &
Server.MapPath("databases/apprequests.mdb") & ";"

Set cnReq = Server.CreateObject("ADODB.Connection")

cnReq.open strConn,,129 // -> THIS IS LINE 9 which is causing the error !

cnReq.AddNewRequest "John", "Doe" // -> AddNewRequest is a add query
which resides inside the database with two params

%>

I just have to overlook something but what?

I checked file, folder, internet security settings and all are ok.

The system.mdw resides in the same folder where the database is stored.

Now, i'm allready bald but if i still had some hair left they were all gone
by now!

Note that i've several other databases which resides in the same folder and
there i'm not having any errors at all!




"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> schreef in bericht
news:%23pKxS0u0EHA.1932@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

Philmans
11/26/2004 6:56:08 AM
Thanks Bob,

That just solved it.

I think i was staring to intense to this code that i just didn't see
anything wrong.


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> schreef in bericht
news:OUcZBoz0EHA.824@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button