-
Accessing Database
Ok, so on a page, I want to access an Access Database I created. I just want to show some names and a link to a page with an id attached.
I create my database using:
Code:
dim cnn
set cnn = server.createobject("ADODB.connection")
with cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = Server.MapPath("/S5047049/HerEx/Include") & "/Studeerwijzer.mdb"
.open
end with
Then I open a recordset with
Code:
dim rst, strOpen
set rst = server.CreateObject("ADODB.Recordset")
strOpen = "Select * from tblOpleiding order by OpleidingNaam"
rst.Open strOpen, cnn, adOpenStatic, adLockOptimistic
And I show the data with:
Code:
<%= rst.Fields("opleidingNaam") %>
In between is a bit of HTML code, but nothing of matter.
The odd thing is, when I execute this on my server. I get the following error:
ADODB.Recordset error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/s5047049/HerEx/studeerwijzerKeuze.asp, line 42
Line 42 is:
Code:
rst.Open strOpen, cnn, adOpenStatic, adLockOptimistic
Anybody got an idea where I did something wrong?
-
This looks like ASP code so I'm assuming that somewhere in your code you have defined values for adOpenStatic and adLockOptimistic?
Paul
~~~~
Microsoft MVP (Visual Basic)
-
Nop, those are standard values that you can choose when you type in:
Code:
rst.Open strOpen, cnn,
Once that is typed you get a drop down box with 4 choices and those are one of the choices.
-
OK, try replacing those variables with their actual values (3 and 3) and see what happens when you run the code.
Paul
~~~~
Microsoft MVP (Visual Basic)
-
-
Yeah, I'm back with a new question. (I got a feeling there are a lot of questions going to follow. )
I can access my database normally, no problem there. But when I run a query on my local database it returns 3 values. When I want to show those three values on my webpage, he leaves out the middle value. Any ideas?
-
The reason it works is because ASP doesn't have global access to the values of adOpenStatic and adLockOptimistic in the ADODB library. That's why you have to define them in your code if you want to use them.
Paul
~~~~
Microsoft MVP (Visual Basic)
-
 Originally Posted by Armaron
Yeah, I'm back with a new question. (I got a feeling there are a lot of questions going to follow.  )
I can access my database normally, no problem there. But when I run a query on my local database it returns 3 values. When I want to show those three values on my webpage, he leaves out the middle value. Any ideas?
You will probably need to post some code so that we can see what you are doing.
Paul
~~~~
Microsoft MVP (Visual Basic)
-
Ok, code first, explanation later:
Code:
strOpen = "Select * from tblOpleidingsOnderdeel where OpleidingsOndID in
(select OpleidingsOndID from tblOnderwijsActiviteit where OpleidingID = " &
Request.QueryString("opleidingID") & ") order by OpleidingsOnderdeelNaam"
rst.Open strOpen, cnn, 3, 2
Response.Write("<h3>" & Request.QueryString("naam") & "</h3>")
do while not rst.EOF
Response.Write("<li><a href=""./studeerwijzerKeuze.asp?oo=" & rst.Fields("OpleidingsOndID") &
"&opleidingID=" & Request.QueryString("opleidingID") & "&naam=" &
Request.QueryString("naam") & "&oplond=" & rst.Fields("OpleidingsOnderdeelNaam") & """>" &
rst.Fields("OpleidingsOnderdeelNaam") & "</a></li>")
rst.MoveNext
loop
strOpen is my SQL statement. I ran the statement on my local database (it's just an Access database on my server) and there it gives three output lines. On my website just two. I replaced the "Request.QueryString("opleidingID")" with a value that would be implemented if I would use it on the server. So that I was sure that I am using the same values as when I click my link that leads to this bit of code.
the Do While Loop is the space where the recordset is printed to my screen.
Last edited by Armaron; 07-19-2007 at 09:02 AM.
Similar Threads
-
Replies: 1
Last Post: 03-12-2007, 09:56 AM
-
By Jim in forum VB Classic
Replies: 3
Last Post: 07-04-2002, 02:38 AM
-
By jim in forum VB Classic
Replies: 5
Last Post: 03-23-2001, 01:53 PM
-
By Steven Reid in forum VB Classic
Replies: 1
Last Post: 08-12-2000, 09:25 AM
-
By Jeff in forum VB Classic
Replies: 2
Last Post: 06-16-2000, 03:38 PM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|