|
-
Apr 17th, 2000, 08:09 PM
#1
Help! Please please help!! 
I'm trying to figure out how to add a record to a table in a database. I've got:
Code:
dim oRSu
set oRSu = Server.CreateObject("ADODB.Recordset")
oRSu.Open "users","DSN=fbquiz"
oRSu.AddNew
oRSu("Name") = sName
oRSu("Address") = sAddress
oRSu("Town") = sTown
oRSu("County") = sCounty
oRSu("Post_Code") = sPostCode
oRSu("Country") = sCountry
oRSu("EMail") = sEMail
oRSu("User_Name") = sUsername
oRSu("Password") = sPassword
oRSu.Update
set oRSu = Nothing
but I keep getting "The operation requested by the application is not supported by the provider." on the "oRSu.AddNew" line.
What am I doing wrong?
-
Apr 17th, 2000, 08:24 PM
#2
Frenzied Member
I always use SQL to interact with databases in ASP. I know that doesn't help, but maybe you should try it because I know it works
Harry.
"From one thing, know ten thousand things."
-
Apr 17th, 2000, 08:26 PM
#3
Go on then, Harry, what's the sequel code to do it?
-
Apr 17th, 2000, 09:57 PM
#4
It happens not because you open Table based recordset, but because you didn't specify the CursorType for your recordet. The default is adOpenForwardOnly, which is not updatable. If you want your recordset to be updatable, you have to open it as adOpenKeyset or adOpenDynamic. So your code should be like this:
Code:
<%
Dim oRSu
Set oRSu = Server.CreateObject("ADODB.Recordset")
oRSu.Open "users","DSN=fbquiz", adOpenKeyset
oRSu.AddNew
oRSu("Name") = sName
oRSu("Address") = sAddress
oRSu("Town") = sTown
oRSu("County") = sCounty
oRSu("Post_Code") = sPostCode
oRSu("Country") = sCountry
oRSu("EMail") = sEMail
oRSu("User_Name") = sUsername
oRSu("Password") = sPassword
oRSu.Update
Set oRSu = Nothing
%>
-
Apr 17th, 2000, 10:08 PM
#5
Ta Serge...but I was still getting some error about the currect recordset not supporting the addnew function.
A collegue at work just sugested:
Code:
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open("DSN=fbquiz")
Set oRSu=Server.CreateObject("ADODB.Recordset")
oRSu.Open "users",Conn,3,3
oRSu.Addnew
oRSu("Name") = sName
oRSu("Address") = sAddress
RSu("Town") = sTown
oRSu("County") = sCounty
oRSu("Post_Code") = sPostCode
oRSu("Country") = sCountry
oRSu("EMail") = sEMail
oRSu("User_Name") = sUsername
oRSu("Password") = sPassword
oRSu.Update
set oRSu = Nothing
set conn=nothing
which seems to work ok now.
-
Apr 17th, 2000, 10:17 PM
#6
The reason for that is because VBScript didn't undertand adOpenKeyset constant, because you didn't reference ADO object library.
In your code 3 means adOpenKeyset, in other words, adOpenKeyset constant has a value of 3.
That's it.
-
Apr 17th, 2000, 10:21 PM
#7
LOL!! I've just been looking through the code and messin about and come to the same conclusion.
If I use my collegue's code but with the constants instead of 3 it produces the same error as my code.
So why does Visual Interdev suggest these constants if the ASP interpreter doesn't understand them? Mad that!!
Anyway...works now and I'm back to using my original code...with ", 3, 3" tagged on the end of the open line.
Thanks Serge.
-
Apr 17th, 2000, 10:54 PM
#8
Frenzied Member
You should have the file 'adovbs.inc' somewhere around. To use the ADO constants in VBScript you need the line
Code:
<!-- #include file="adovbs.inc" -->
at the beginning of your script. Put the adovbs.inc file in the same directory as the script you are running. You could , alternatively, put
Code:
<!-- #include virtual="/the/file/path/adovbs.inc" -->
if you wanted to keep it somewhere else and reference it by it's virtual location.
Harry.
"From one thing, know ten thousand things."
-
Apr 17th, 2000, 11:10 PM
#9
Ah! And that file has constants like:
adOpenKeyset
adLockPessimistic
I kinda thought that these constants were build into the asp interpreter...like all the "vb..." constants in vb...suppose they are actually contained in the runtime dlls that asp doesn's have...not being vb and all.
Oh well whatever. It works now and i've learned something so that's all i care about. 
Cheers everyone!
-
Apr 17th, 2000, 11:33 PM
#10
Frenzied Member
Yeah it was kind of a revelation to me too 
Maybe now I'll be able to get those fricking bookmarks to work! 
Harry.
"From one thing, know ten thousand things."
-
Apr 17th, 2000, 11:39 PM
#11
sorry! what? what bookmarks? :?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|