Avatar billede gemini Nybegynder
04. april 2002 - 11:31 Der er 4 kommentarer og
1 løsning

ADO vs ODBC - very fishy - help!

Hi there!

Have a quite bizzare problem that I hope someone can help me with - rather quickly too ;)

Well well, I decided to give an ADO-connection in the ASP-code instead of the regular ODBC-connection - since it apparently is quite much quicker. According to 4guysFromRolla this should be fairly easy - just change your connectionString from :

"DSN=hubbaHubba;UID=hubbaUser;PWD=hubbaPassword;"

to:

"Provider=SQLOLEDB; Data Source=11.11.11.200; Initial Catalog=hubbaHubbaDB; User ID=hubbaUser; Password=hubbaPassword;"

Ok, so everythings is fine - for a start that is.
I "start it up", with the usual
"objConn.Open(myConnectionString);" etc

But after trying to do a :
"var rs = objConn.Execute("myStoredP 1,4,'whatever');"

followed by the standard way of putting things :
"while (!rs.EOF) {"

it halts - telling me that the action is not allowed when the object is closed!?!!??! And I can guarantee that my objConn in no way is closed... I even tried it by removing the objConn.Close...

A closer inspection shows that the while-loop in itself is ok to perform - as long as I don't try to retrieve any data from the recordset, like
"var firstName = String(rs("firstName"));"

Strange huh? Well even stranger it will become; Just to try things out I performed the following:

"objConn.Execute("select * from users")"

which worked just ok allowing me to retrieve and print data from the recordset.

So I subsequently tried the following:

"objConn.Execute("listAdminUsers 1")" - ("1" - being the single value to be submitted to the storedProcedure)

After executing the above, I was quite amazed to see that I actually could retrive data from the executed storedProcedure - leaving me with the conclusion that the recordsets delivered by my storedProcedures and ADO actually worksfine together.

Now the difference between the first storedProcedures and the last one, is that the first had much more arguments. Leading me to suspect that this is where my problem lies. Ie, the way that arguments/variables are submitted to the storedProcedure differs from ADO and ODBC.

Well well, I hope that somebody can offer any help =) I'm running an IIS on NT4 and a SQL2000 server on a seperate machine. Btw, using the Command-object is not an option - to many lines of code to rewrite ;)

Peace & and many thanks in advance,
Gemini
Avatar billede olhansen Nybegynder
04. april 2002 - 14:02 #1
Hi

I dont know if it will affect anything, but there are other possibilities when opening a connection and a recordset.
When opening the connection you can use an other provider:

Set Conn = Server.CreateObject("ADODB.Connection")
dbNavn=Server.MapPath("..\..") & "/data/mydb.mdb
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.Open dbNavn,"",""

I use access, thats why I use the JET provider. You will have to use an other provider for SQL Server.



When creating then ADODB.Recordset you are able to first create the object, and open it afterwards, giving the open connection as second argument:

Dim RS2
Set RS2=Server.CreateObject("ADODB.Recordset")
RS2.Open "select * from medarbejdere order by id", conn, adOpenDynamic, adLockOptimistic



Good luck
Avatar billede olhansen Nybegynder
04. april 2002 - 15:09 #2
Howsitgoing?
Avatar billede gemini Nybegynder
04. april 2002 - 15:15 #3
Well, hmmmm, not that well actually. The project as it is now - consists of something like 200 ASP-pages. I really don't have the oppurtunity to change my codeblocks from objConn.Execute to (for example) RS2.Open :(

But I really could use the connectin boost it would give to leave ODBC behind and adapt ADO... Any more suggestions?

Peace,
Gemini
Avatar billede coltau Juniormester
04. april 2002 - 16:51 #4
I believe that there is a difference between the 2 way of connection and that the new connection dosent have the same permissions as the old one.

If you use this: "DSN=hubbaHubba" - then the permissions is granted to a kind of process that is created/running at the SERVER. (A DSN-process that communicate with youer ASP)

If you use this: "Provider=SQLOLEDB; Data Source=11.11.11.200; Initial Catalog=hubbaHubbaDB"
then the permissions is granted to a connection-process that is running at your CLIENT.

and I believe that there is a slight difference when it comes to getting access to a recordset created by a Stored Procedure on the Server.

There have to be more difference between your 2 Stored Procedure than the parametres.

What kind of CursorType and CursorLocation do they use. ?

If the location is on the Server - who provide your client-process with the RS.Fields-information when you ask for it. (When the error come) It is not the Stored Procedure. The Stored Procedure deliver a recordset "somewhere private" witch no CLIENT-process can see because the location=Server. But a DSN-process have that permission. !

Maybe I'm wrong - but it was the best I could think of.

Luck.
Avatar billede gemini Nybegynder
29. august 2002 - 12:44 #5
Thanks! I'll truy that one - it will most probably fix my problems =)
Peace,
Gemini
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester