|
Home > Archive > SQL Anywhere for Linux > January 2006 > Connecting to Server from C, example?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Connecting to Server from C, example?
|
|
| Jason Boardman 2006-01-06, 8:23 pm |
| Hi,
Could someone point me to an example somewhere describing how to connect
to my 9.0.2 server from within a C program? The C program and DB server
engine are running on the same machine (linux RH9). Or, if anyone is so
inspired, post one here?
Thanks,
Jason Boardman
| |
| Chris Keating(iAnywhere Solutions) 2006-01-06, 8:23 pm |
| Go to the samples folder in the install directory.
You have a number of options for connectivity -- embedded SQL and ODBC.
Each will use different techniques to establish the connection. For
examples, see the samples directory in the install root directory.
--
Chris Keating
Sybase Adaptive Server Anywhere Professional Version 8
********************
********************
********************
*****************
Sign up today for your copy of the SQL Anywhere Studio 9 Developer
Edition =and try out the market-leading database for mobile, embedded
and small to medium sized business environments for free!
http://www.ianywhere.com/promos/deved/index.html
********************
********************
********************
*****************
iAnywhere Solutions http://www.iAnywhere.com
** Please only post to the newsgroup
** Whitepapers can be found at http://www.iAnywhere.com/developer
** EBFs can be found at http://downloads.sybase.com/swx/sdmain.stm
** Use Case Express to report bugs http://case-express.sybase.com
********************
********************
********************
*****************
| |
| Jason Boardman 2006-01-11, 8:23 pm |
| I checked through the examples in my install directory - didn't seem to
be much for C. Just the mainch.c, odbc.c, and example.h. Maybe i'm just
confused by them. There are miles of examples out there to connect to
databases using DBI from perl - this is exactly what I want to do but
from C. Is there not just a straightforward code example out there that
say, connects to the database (running on the same machine, using ODBC
or not) passes a simple SQL command to the server like "select current
timestamp from dummy" and spits the result to the standard output? Is
this harder than it sounds? Using perl it would be a snap- I can't
imagine the C solution being that much more complex. Am I wrong? I've
googled the universe looking for something simple like this to no avail.
i can't find anything in codexchange either. Any brave soul feel like
posting it here?? I'm sure there must be others out there similarly lost.
Jason Boardman
Chris Keating(iAnywhere Solutions) wrote:
> Go to the samples folder in the install directory.
>
> You have a number of options for connectivity -- embedded SQL and ODBC.
> Each will use different techniques to establish the connection. For
> examples, see the samples directory in the install root directory.
| |
| Reg Domaratzki \(iAnywhere Solutions\) 2006-01-11, 8:23 pm |
| Here's a C sample that simply connects to the database and then disconnects.
It uses Embedded SQL, which you may or may not want. It's a windoze sample
as opposed to Unix, but it would probably take about 1 minute for a UNIX
person to translate the makefile to UNIX-speak. It simple executes sqlpp on
the .SQC file and then compiles the app.
YOu may also want to read over the following sections in the docs. It's an
overview of Embedded SQL programming, and the 6th topic includes a simple
sample, that is actually more complicated than the attached file.
ASA Programming Guide
Embedded SQL Programming
Introduction
--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup
iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set filter to "Display ALL platforms IN ALL MONTHS"
"Jason Boardman" < nospam_jasonboardman
_@_gmail_._com> wrote in message
news:43c56321@forums
-2-dub...[color=darkred]
> I checked through the examples in my install directory - didn't seem to
> be much for C. Just the mainch.c, odbc.c, and example.h. Maybe i'm just
> confused by them. There are miles of examples out there to connect to
> databases using DBI from perl - this is exactly what I want to do but
> from C. Is there not just a straightforward code example out there that
> say, connects to the database (running on the same machine, using ODBC
> or not) passes a simple SQL command to the server like "select current
> timestamp from dummy" and spits the result to the standard output? Is
> this harder than it sounds? Using perl it would be a snap- I can't
> imagine the C solution being that much more complex. Am I wrong? I've
> googled the universe looking for something simple like this to no avail.
> i can't find anything in codexchange either. Any brave soul feel like
> posting it here?? I'm sure there must be others out there similarly lost.
>
> Jason Boardman
>
> Chris Keating(iAnywhere Solutions) wrote:
Att. was here
| |
| Chris Keating(iAnywhere Solutions) 2006-01-11, 8:23 pm |
| Find attached an example showing ODBC connectivity. You will need to
modify the NT header file references to the UNIX equivalent headers.
See the programming guide for more details.
--
Chris Keating
Sybase Adaptive Server Anywhere Professional Version 8
********************
********************
********************
*****************
Sign up today for your copy of the SQL Anywhere Studio 9 Developer
Edition =and try out the market-leading database for mobile, embedded
and small to medium sized business environments for free!
http://www.ianywhere.com/promos/deved/index.html
********************
********************
********************
*****************
iAnywhere Solutions http://www.iAnywhere.com
** Please only post to the newsgroup
** Whitepapers can be found at http://www.iAnywhere.com/developer
** EBFs can be found at http://downloads.sybase.com/swx/sdmain.stm
** Use Case Express to report bugs http://case-express.sybase.com
********************
********************
********************
*****************
| |
| Jason Boardman 2006-01-12, 1:23 pm |
| A million thanks Chris and Reg! This is exactly what I needed!!
Jason
[color=darkred]
>Jason Boardman wrote:
> I checked through the examples in my install directory - didn't seem to
> be much for C. Just the mainch.c, odbc.c, and example.h. Maybe i'm just
> confused by them. There are miles of examples out there to connect to
> databases using DBI from perl - this is exactly what I want to do but
> from C. Is there not just a straightforward code example out there that
> say, connects to the database (running on the same machine, using ODBC
> or not) passes a simple SQL command to the server like "select current
> timestamp from dummy" and spits the result to the standard output? Is
> this harder than it sounds? Using perl it would be a snap- I can't
> imagine the C solution being that much more complex. Am I wrong? I've
> googled the universe looking for something simple like this to no avail.
> i can't find anything in codexchange either. Any brave soul feel like
> posting it here?? I'm sure there must be others out there similarly lost.
>
> Jason Boardman
>
> Chris Keating(iAnywhere Solutions) wrote:
>
|
|
|
|
|