| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

01-14-04, 20:54
|
|
Registered User
|
|
Join Date: Dec 2003
Location: Brisbane
Posts: 14
|
|
accessing a table from a database
|
|
I'm using the following script to access a table from a database but I'm getting the following error message... Can someone check over the code and see where I'm going wrong???
<% @ Language="VBScript" %>
<% Option Explicit %>
<%
Dim server.CreateObject, sConnString, connection.Open, Response.Write
server.CreateObject("ADODB.recordset")
sConnString="DSN=database1"
connection.Open "People"
Response.Write ("People").Value
%>
########################
ERROR MESSAGE
Sun ONE ASP VBScript compilation (0x800A0401)
Syntax error, unexpected ".", expecting end of statement
/test.asp, line 4, column 11
############################
|
|

01-14-04, 22:19
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Your code would look a lot better like this....
Code:
<% @ Language="VBScript" %>
<% Option Explicit %>
<%
Dim PeopleRS, sConnString, myConn, mySQL
Set myConn= server.CreateObject("ADODB.Connection")
sConnString="DSN=database1"
myConn.Open sConnString
mySQL = "Select * from People"
Set PeopleRS = myConn.Execute(mySQL)
Response.Write PeopleRS("fieldname").value
%>
The above won't work perfectly either, but it's a lot closer to what you are looking for. If you provide more details about your database and the tables and the data and exactly what you are trying to do I'm sure someone can help.
|
|

01-14-04, 23:53
|
|
Registered User
|
|
Join Date: Dec 2003
Location: Brisbane
Posts: 14
|
|
|
extract the contents of a table
|
|
Thanks rokslide,
What I'm after is a script which will extract the contents of a table from an access database so they are displayed on an .asp page.
Your recent contribution was way better than mine.
Perhaps you could help further with the extra info:
Database name: database1
Table name: People
The 3 fields within table include: ID, People, Comment
Cheers
<% @ Language="VBScript" %>
<% Option Explicit %>
<% Dim PeopleRS, sConnString, myConn, mySQL
Set myConn= server.CreateObject("ADODB.Connection")
sConnString="DSN=database1"
myConn.Open sConnString mySQL = "Select * from People"
Set PeopleRS = myConn.Execute(mySQL)
Response.Write PeopleRS("fieldname").value
%>
By the way... I'm still getting this error message now:
Sun ONE ASP VBScript compilation (0x800A0401)
Syntax error, unexpected "identifier", expecting end of statement
/test.asp, line 6, column 25
|
Last edited by davep23; 01-15-04 at 00:11.
|

01-15-04, 00:13
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Okie, the problem you have in the code you have posted back to me is that you have joined two lines together.
Line 6 ends after sConnString, line 7 starts at mySQL.
With ASP/VBScript there is no end statement identifier (like the ; in C) so you have to be a bit more careful about when you start and end you lines...
try this code...
Code:
<% @ Language="VBScript" %>
<% Option Explicit %>
<%
Dim PeopleRS, sConnString, myConn, mySQL
Set myConn= server.CreateObject("ADODB.Connection")
sConnString="DSN=database1"
myConn.Open sConnString
mySQL = "Select * from People"
Set PeopleRS = myConn.Execute(mySQL)
Response.Write "<table>"
do while not PeopleRS
Response.Write "<tr>"
Response.Write "<td>" & PeopleRS("ID").value & "</td>"
Response.Write "<td>" & PeopleRS("People").value & "</td>"
Response.Write "<td>" & PeopleRS("Comment").value & "</td>"
Response.Write "</tr>"
PeopleRS.MoveNext
loop
Response.Write "</table>"
Set PeopleRS = nothing
Set myConn = nothing
%>
Have you set up the DSN you used above??
|
|

01-15-04, 00:23
|
|
Registered User
|
|
Join Date: Dec 2003
Location: Brisbane
Posts: 14
|
|
I've set up my DSN so that should be OK.
I tried the lastest code and I can see what you mean but now I'm getting this strange error message:
########
ADODB.Connection.1 (0x80004005)
SQLState: S1000 Native Error Code: -1045 [DataDirect][ODBC SequeLink driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Not a valid bookmark.
/test.asp, line 7
#########
which is: myConn.Open sConnString ???
try this code...
Code:
<% @ Language="VBScript" %>
<% Option Explicit %>
<%
Dim PeopleRS, sConnString, myConn, mySQL
Set myConn= server.CreateObject("ADODB.Connection")
sConnString="DSN=database1"
myConn.Open sConnString
mySQL = "Select * from People"
Set PeopleRS = myConn.Execute(mySQL)
Response.Write "<table>"
do while not PeopleRS
Response.Write "<tr>"
Response.Write "<td>" & PeopleRS("ID").value & "</td>"
Response.Write "<td>" & PeopleRS("People").value & "</td>"
Response.Write "<td>" & PeopleRS("Comment").value & "</td>"
Response.Write "</tr>"
PeopleRS.MoveNext
loop
Response.Write "</table>"
Set PeopleRS = nothing
Set myConn = nothing
%>
|
|

01-15-04, 00:31
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Hmmm, well it's been ages since I have used a DSN or Access or ASP, but at a guess I would say that message is likely to be because of the DSN not being set up properly....
Can you do something like...
Code:
<% @ Language="VBScript" %>
<% Option Explicit %>
<%
Dim PeopleRS, sConnString, myConn, mySQL
Set myConn= server.CreateObject("ADODB.Connection")
sConnString="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\IP_ADDRESS\MY_PATH\Database1.mdb;" & _
"Jet OLEDB"
myConn.Open sConnString
mySQL = "Select * from People"
Set PeopleRS = myConn.Execute(mySQL)
Response.Write "<table>"
do while not PeopleRS
Response.Write "<tr>"
Response.Write "<td>" & PeopleRS("ID").value & "</td>"
Response.Write "<td>" & PeopleRS("People").value & "</td>"
Response.Write "<td>" & PeopleRS("Comment").value & "</td>"
Response.Write "</tr>"
PeopleRS.MoveNext
loop
Response.Write "</table>"
Set PeopleRS = nothing
Set myConn = nothing
%>
but replace IP_ADDRESS, MY_PATH so that you are pointing to the right MDB file?
|
|

01-15-04, 00:41
|
|
Registered User
|
|
Join Date: Dec 2003
Location: Brisbane
Posts: 14
|
|
DSN ok
Checked DSN and it's ok.
But could it be a problem relating to SunOne ASP?
Server supplier does not support MY_PATH (DSNless) only DSN so I have to use: sConnString="DSN=database1"
Bugger!!!
|
|

01-15-04, 00:45
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Could be,.. I have never used SunOne ASP. How does it different from standard asp?
|
|

01-15-04, 00:52
|
|
Registered User
|
|
Join Date: Dec 2003
Location: Brisbane
Posts: 14
|
|
SunOne is a Unix based server not Windows based server. SunOne is capable of treating ASP and databases like Windows but has its own complications and idiosyncrasies.
Your advice and coding has been most helpful. If you or other members come up with any other suggestions let me know.
Quote:
Originally posted by rokslide
Could be,.. I have never used SunOne ASP. How does it different from standard asp?
|
|
|

01-15-04, 00:56
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Does it use the standard MDAC components or does it use some sort of "copy" to do what MDAC does?
|
|

01-15-04, 01:02
|
|
Registered User
|
|
Join Date: Dec 2003
Location: Brisbane
Posts: 14
|
|
copy" I believe...
It uses a "copy" I believe. Other than that... ????
I know that Access can be used on Unix and SunOne and the Jet Drivers are used as with Windows Servers (except for a few changes).
Quote:
Originally posted by rokslide
Does it use the standard MDAC components or does it use some sort of "copy" to do what MDAC does?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|