C language > Beginner questions

Working with databases

(1/2) > >>

Zodra1:
Hi again,

I browsed and searched this forum for a couple of hours and I can't find anything about working with data(bases). How do I connect to a database e.g. MS SQL, Or any other database? Can I use SQL statements directly in code?

Regards,
Drago

Pelle:
Connecting to a database usually depends on the database. ODBC (see http://en.wikipedia.org/wiki/Open_Database_Connectivity) is/was one attempt at supporting multiple databases through a common interface - I'm not sure how much it's used today. The SQL statements are most likely passed as strings to some API function that the database provides. I use SQLite in Pelles C, which is small and easy database engine to start with (see http://www.sqlite.org/). It works fine, unless you want to handle *huge* volumes of data...

TimoVJL:
If you are interest about ODBC look at:
http://forum.pellesc.de/index.php?topic=2489.msg9458#new

Zodra1:
Thank both for the answers. I would prefer something like MSDE. If possible

TimoVJL:
You can connect to SQL Server or MSDE via ODBC, OLE DB, or DB-Library.
What you prefer to use except ODBC ?

DB-Library example code just for keywords to google.

--- Code: ---// MSSQL database
PDBPROCESS dbproc; // The connection with SQL Server.
PLOGINREC login; // The login information.

int err_handler(PDBPROCESS, INT, INT, INT, LPCSTR, LPCSTR);
int msg_handler(PDBPROCESS, DBINT, INT, INT, LPCSTR, LPCSTR,
LPCSTR, DBUSMALLINT);
dberrhandle(err_handler);
dbmsghandle (msg_handler);
login = dblogin();
dbsetlname(login, 0, DBSETSECURE);
dbproc = dbopen(login, "local");
dbuse(dbproc, "test");
dbexit();

--- End code ---


Navigation

[0] Message Index

[#] Next page

Go to full version