473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

database connectivity through C program

Hi to all,
Can it is possible to connect to the databse like postgre or mysql
through a C programm?

I know the basics of C and I have developed a small program which uses
a file for the repositary of the data.But I want to use a database for
this, insted of file.

If possible please give some Code snippets for the connectivity as well
as how to run the queries.

Thanks Junaid

Nov 14 '05 #1
3 2072

"junaid" <ju*********@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi to all,
Can it is possible to connect to the databse like postgre or mysql
through a C programm?

I know the basics of C and I have developed a small program which uses
a file for the repositary of the data.But I want to use a database for
this, insted of file.

If possible please give some Code snippets for the connectivity as well
as how to run the queries.

Thanks Junaid


Database connectivity isn't part of the C language per-se, so isn't really
on-topic for this group.
But yes, you can certainly use C to connect to PostgreSQL or MySQL.
You need to read the documentation for PostgreSQL and/or MySQL, where they
show how, and show examples.
Nov 14 '05 #2
"junaid" <ju*********@yahoo.com> writes:
Can it is possible to connect to the databse like postgre or mysql
through a C programm?


Undoubtedly. Check the documentation of whatever database you're
using, or post to a newsgroup that deals with databases. It can't be
done in *portable* C, so we can't discuss it here.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #3

"junaid" <ju*********@yahoo.com> wrote

Can it is possible to connect to the databse like postgre or mysql
through a C programm?
Normally by calling library functions supplied by the databse vendor, or
maybe third parties, just as you would any other function.
I know the basics of C and I have developed a small program which uses
a file for the repositary of the data.But I want to use a database for
this, insted of file.

If possible please give some Code snippets for the connectivity as well
as how to run the queries.

Unfortunately we don't discuss non-ANSI libraries on this ng. However we do
discuss how to use such libraries in a general way.

This would be typical code.

#include <stdio.h>
#include <library_specific_header>

void yourfunction()
{
THEIRTYPE x;
int result;
x = theirfunction("a string parameter");
result = theirotherfunction(x);
printf("Their library gave me this result %d\n", result)'
}

When you compile, some compilers will ask you to link the library, which may
involve knowing where it is physically kept and what the filename is. Others
will do this automatically.
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SectorUnknown | last post by:
I've written a database (Access mdb) front-end using Python/wxpython/and ADO. However, the scope of the project has changed and I need to access the same data on an MSSQL server. Also, the...
3
by: Alex | last post by:
I have developed a VB application that uses Oracle 8i database for backend. The database server is on the local network. From my development machine, the application connects (via ODBC) to the...
1
by: harish | last post by:
I am using java applications to connect to my MS SQL Server database. I am using ODBC for database connectivity. If i am running my java applications in a remote PC and try to connect to database...
2
by: Rosy Moss | last post by:
I am in the process of cleaning up a database that our company uses to track jobs, time and expense, and customer information. We are running Windows 2000 Server with approximately 20 terminals...
3
by: Niks | last post by:
Hi, I need to connect to SQL server Database using a System DSN. Can anyone tell me how to connect to SQL Server using DSN in ASP.NET (VB.Net). Using a Try Catch block. Does anyone know how to...
8
by: David | last post by:
Hi, Could someone please xplain how to add a field to an existing SQL table in VB.Net I have added the field in the Server Explorer and it shows up when I reload the program but I cannot...
47
by: Ivan Weiss | last post by:
Hi all, I am just getting started on a new app and am a rusty VB6 guy who is looking to create something on the side to serve as a corporate workbench for my company. ADO.net is new to me so...
0
by: dalaimanoj | last post by:
I have a form with buttons 'View', 'Save', 'Delete', 'Edit' and some textboxes to input data.. On clicking each buttons the database is connected and the respective action is done. For example...
1
Curtis Rutland
by: Curtis Rutland | last post by:
How To Use A Database In Your Program Part II This article is intended to extend Frinny’s excellent article: How to Use a Database in Your Program. Frinny’s article defines the basic concepts...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.