Page 1 of 1 1
Topic Options
#87344 - 2002-08-19 05:20 PM Reading from database
punkie Offline
Getting the hang of it

Registered: 2002-06-23
Posts: 67
I can't seem to figure out how to get data from a access database, I've looked around but not much luck.

I'm a bit more familiar with MySQL but these don't seem to work exactly the same, at least not the scripting part.

By the way, does anyone know how it's stored in the database? I was thinking something like:
$getstuff = $dbquery[0]

Top
#87345 - 2002-08-19 06:13 PM Re: Reading from database
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Lokk up the following UDFs in the UDf forum:
DBConnOpen() @ http://81.17.37.55/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000194
DBConnclose() @ http://81.17.37.55/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000195
DBExecuteSQL() @ http://81.17.37.55/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000196
DBGetRecordset() @ http://81.17.37.55/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000197
DBRecordsetOpen() @ http://81.17.37.55/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000198
DBRecordsetClose() @ http://81.17.37.55/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000199
_________________________
There are two types of vessels, submarines and targets.

Top
#87346 - 2002-08-19 07:32 PM Re: Reading from database
punkie Offline
Getting the hang of it

Registered: 2002-06-23
Posts: 67
Hmmm, I still can't seem to get it to work. I can't understand what i'm doing wrong but this is what I came up with. I hope someone can help me out with this one...

code:
$objConn = DBConnOpen('DRIVER={Microsoft Access Driver (*.mdb)}; UID=; PWD=; DBQ=C:\test.mdb')
$recordset = DBRecordsetOpen($objConn,'SELECT * FROM MyTable')

if $objConn
$numRecords=$recordset.RecordCount
? "Records: "+$numRecords
else
?"error"
endif

$retcode = DBRecordsetClose($recordset)
$retcode = DBConnClose($objConn)

Edit: oops, had a mispelling - still same problem though.

[ 19. August 2002, 19:36: Message edited by: punkie ]

Top
#87347 - 2002-08-20 01:45 PM Re: Reading from database
punkie Offline
Getting the hang of it

Registered: 2002-06-23
Posts: 67
This seems to work in VBScript but I can't be able to port to Kix, not to get it working anyway. Anyone have an idea what i'm doing wrong?

VBScript:
code:
Dim connect, connect_str, query, output, msg

Set connect = CreateObject("ADODB.Connection")
connect_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb"
connect.Open connect_str

query = "SELECT * FROM MyTable"
Set query = connect.Execute(query)

Do while not query.EOF
output = query("MyRecord")
query.movenext
loop

msg = "Results: " &output
msgbox msg

And the kix script:
code:
break on

$connect = CreateObject("ADODB.Connection")
$connect_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb"
$connect.Open($connect_str)

$query = "SELECT * FROM MyTable"
$query = $connect.Execute($query)

while not $query.EOF
$output = $query("MyRecord")
$query.movenext
loop

? "Results: " + $output


Top
#87348 - 2002-08-30 11:58 AM Re: Reading from database
Anonymous
Unregistered


Hi Punkie,

try replacing:

code:
 $output = $query("MyRecord") 

with:

code:
 $output=$output+$query.Fields("MyRecord").value 

This works for me.

Cheers,
Michael.

Top
#87349 - 2002-08-31 06:32 AM Re: Reading from database
punkie Offline
Getting the hang of it

Registered: 2002-06-23
Posts: 67
Haven't had time to play around with the DB stuff since my last post, never got it working however. I tried your suggestion Michael, it results in:

Script error: IDispatch pointers not allowed in expressions!

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.054 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org