Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2004, 11:11 AM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Seb_soum
Default Arguments are of the wrong type????

I dont get this anymore.....I'm pretty bad at ASP, but could someone help me on this one???
My code is as follows:
<html>

<head>
<title></title>
<%
dim rs, data_source, strSQLQuery, sName, fName, Dept
sname = request.form("SName")
fName = request.form("fName")
dept = request.form("Dept")
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
        Server.MapPath("Overtime.mdb")
        set rs = Server.CreateObject("ADODB.Recordset")
        strQL = "SELECT * FROM Users;"
        'strSQL = "INSERT INTO Users (Name, Surname, Department) VALUES ('"&fname&"','"&sname&"','"&dept&"')"

        rs.Open strSQL, data_source

%>
</head>
<body>
<%
    rs.addnew
        rs.Fields("Name") = Request.Form("FName")
        rs.Fields("Surname") = Request.form("SName")
        rs.Fields("Department") = Request.form("Dept")
    rs.Update

    rs.close
    set rs = nothing
    set data_source = nothing
Response.write request.form("FName") & " " & request.form("Sname") & " from the " & request.form("Dept") & "has been added!"

%>
</body>
</html>


The thing is, I've looked at a few tutorials, and they're telling me its right.....but I must be dumb, cause I get the following error:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/Add_User.asp, line 19
 
Old May 8th, 2004, 11:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

This error usually indicates that you have made an error in the connection string, you have chosen to use is inappropriate, or some parameter is incorrect. The basic connection to your database could not be established. Edit your Connection string.

This could also indicate a problem with the ODBC driver you are using. You should make sure you have the latest MDAC installed, and your server meets PDshopPro's requirements. Visit Microsoft's site for any MDAC/Jet drivers you may need.

You might want to take a look at http://www.connectionstrings.com
expand ACCESS link there and check if your connection string is correct.

I suspect there should be something wrong with the way you specified your MDB file. Check if the path is right. If it is present in your website/virtualdirectory's root, you should prefix it with a forward slash.

Eg: Server.MapPath("/Overtime.mdb")

check with doing a response.write and see if it give the right path.

response.write Server.MapPath("Overtime.mdb")
Should output something like "c:\inetpub\wwwroot\.....Overtime.mdb"
then check if the mdb file exists in that path.
Else you got to prefix it with a "/" there.

Hope that helps.
Cheers!


-Vijay G
 
Old May 8th, 2004, 11:59 AM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Seb_soum
Default

thanks for the reply....

Its the same connection string for all my other ASP pages....this is the only one that has to add the items.....I did the respone.write server.mappath("overtime.mdb") and it gives me the full loction....It seems to connect to the database alright cause when I change the INSERT INTO statement, it works fine.....I'm pulling my hair out here...
 
Old May 8th, 2004, 12:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Which is line number 19 there? I dont get a clue.

-Vijay G
 
Old May 8th, 2004, 12:25 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look here:

http://www.adopenstatic.com/faq/800a0bb9.asp

I think you specifically need to look at step 3 (which implies you fixed the problems in step 2 first).
I think by not specifying the right Cursor and LockTypes, the recordset you created does not support adding new records.
Either change the type of recordset you create, or use the (faster performing) INSERT INTO statement that you have commented out right now.
Instead of opening the recordset with that statement, you should execute it directly with the Execute method of the Connection object.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 8th, 2004, 01:15 PM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Seb_soum
Default

VIJAY, Line 19 is rs.Open strSQL, data_source
Imar, as I said, I'm a novice.....Not too sure what you or that website meant.
weird stuff tho, I had another ASP insert page on a pc at work, its running 98 with PWS and that works fine. Now I use XP Pro with IIS and it doesnt work....
 
Old May 8th, 2004, 01:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, that Web site said you should define the parameters that you pass to the Open method of the recordset. If you read a bit about it ont hat site, things will become clearer.

Anyway, you can also do this:
Code:
strSQL = "INSERT INTO Users (Name, Surname, Department) VALUES ('" & fname & "', '" & sname & "', '" & dept & "')"
Dim objConn
Set objConn = Server.CreateObject(ADODB.Connection")
objConn.Open data_source
objConn.Execute(strSQL)
objConn.Close()
Set objConn = Nothing
That would be the quickest way to perform the update.

If you take the other route, do this:

1. Follow this page: http://www.adopenstatic.com/faq/800a0bb9step2.asp
This will make constants like adOpenForwardOnly etc available in your page

2. Use this code to insert the new record:
Code:
strQL = "SELECT * FROM Users;"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, data_source, adOpenKeyset, adLockOptimistic, adCmdTable
rs.addnew
rs.Fields("Name") = Request.Form("FName")
rs.Fields("Surname") = Request.form("SName")
rs.Fields("Department") = Request.form("Dept")
rs.Update
rs.Close
Set rs = Nothing
By passing in adOpenKeyset and adLockOptimistic you create a recordset that is updateable.

For more info about Cursors, etc look here:
http://www.adopenstatic.com/faq/jetcursortypes.asp

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 14th, 2004, 08:55 AM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Seb_soum
Default

DOESNT MAKE SENSE AT ALL!!!!!!!!
I have XP PRo at home, did the code on that machine (on IIS)....then I get errors......low and behold
I use it at work, Win98 with Personal Web Server, and it works.....anybody know why?
 
Old May 14th, 2004, 11:28 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, that's no guarantee things work. There is quite a big difference between the two.

Did you follow the steps from the FAQ anyway or did you just assume it wouldn't work? Besides most likely being the solution to your problem, they will also help you writing better and faster code.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Comfortable Liar by Chevelle (Track 2 from the album: Wonder What's Next) What's This?
 
Old May 14th, 2004, 12:11 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can also check security permissions. Although the error message seems to indicate something else, you can check whether the account IIS is running under has sufficient permissions to read from the .MDB file, and write to the folder the database resides in. Since Win98 doesn't support NTFS, this is not an issue, but it may be one on XP.
Also, make sure, how obvious it sounds, that the two databases are the same, and that the database is located in the same folder as the ASP page is (or change the Server.MapPath statement accordingly).

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Kill You by KoRn (Track 14 from the album: Life Is Peachy) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
arguments relay pierre.voisin Javascript 1 February 20th, 2008 06:04 PM
Arguments are of the wrong type, are out of accep jenpitts ASP.NET 2.0 Basics 3 August 14th, 2007 03:00 PM
CreateParameter - wrong type rit01 Classic ASP Databases 2 February 2nd, 2006 08:39 PM
Query on the wrong data type ggiibboo VB Databases Basics 1 January 31st, 2006 07:44 PM
Arguments snowy0 VB.NET 2002/2003 Basics 3 September 3rd, 2004 08:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.