Page 1 of 1 1
Topic Options
#146207 - 2005-08-22 10:13 PM ODBC Query
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
Does anyone have an example of executing an ODBC Query and using the data from that in Kix code? I have not done this and am having a bit of trouble finding examples to template my code after. I am using an access database.

Thanks

Top
#146208 - 2005-08-22 10:17 PM Re: ODBC Query
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
How about this?
ODBCACCESS() - Create an ODBC connection to Access
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#146209 - 2005-08-22 10:21 PM Re: ODBC Query
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
And this site here has syntax for all types

http://www.connectionstrings.com/

Top
#146210 - 2005-08-22 10:29 PM Re: ODBC Query
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
All I am seeing at either location provided is the connection strings. I am actually looking for a full implementation example.
1) making the connection to the (existing) ODBC connection.
2) excuting a query
3) working with the data (I would assume this is a for each loop, but I am uncertain).

Thanks

Top
#146211 - 2005-08-23 04:26 AM Re: ODBC Query
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Can't get any better than DBCommand() - Executes a SQL statement and returns a recordset if applicable
Code:

$dsn='DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=test.mdb'

$sql="INSERT INTO Table1 VALUES('eee','fff')"
$recordset = DBCommand($dsn,$sql)
? 'Error = '+@ERROR+' - '+@SERROR

$sql="SELECT Field1, Field2 FROM Table1
$recordset = DBCommand($dsn,$sql)
? 'Error = '+@ERROR+' - '+@SERROR

for $row=0 to ubound($recordset,1)
for $column=0 to ubound($recordset,2)
? 'Field(row='+$row+', column='+$column+') ='+$recordset[$row,$column]
next
next

_________________________
There are two types of vessels, submarines and targets.

Top
#146212 - 2005-08-23 02:06 PM Re: ODBC Query
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
Many thanks. This appears to be exactly what I was looking for.
Top
Page 1 of 1 1


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

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.062 seconds in which 0.03 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