954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Connect to an SQl server using C language

Hi. plz tell me how I can connect to an SQL server to an microcontroller or a PC using C language....
Plz reply soon....

anu john
Newbie Poster
5 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

How would begin by you demonstrating that you have done something so far (say STFW) or some indication of your skill level.

There is for example no point in explaining anything about SQL if you've yet to master simple "hello world" programs in C.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

How would begin by you demonstrating that you have done something so far (say STFW) or some indication of your skill level.

There is for example no point in explaining anything about SQL if you've yet to master simple "hello world" programs in C.


i have worked in C language ..
just needed some info as to how do i go abt in connecting to a sql server..
hav wrked in c on a beginners level...
hope u'll be able to help me out...

anu john
Newbie Poster
5 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

study these google links about ODBC. There are other ways depending on which SQL server you are using but ODBC is the most portable and is supported by most, if not all, SQL servers today. ODBC, as well as other methods, are somewhat complicated and accessing in c++ is a lot easier because you can get free c++ classes on the net that do most of the work.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Hi again..
i'll be using an sql server 2005 and a microcontroller based system.
s microcontroller does not support any other programming language than c and assembly language.
hope this information will be help u guide me...

anu john
Newbie Poster
5 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

I'd say you have a very big problem then. If the sql server is running on another computer (which it probably does) then your microcontroller and the hardware it runs on will have to support sockets and have a lan card, much like a pc that's connected to a network. If your microcontroller does not support that then you are SOL.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Ye. it will be a kit with ethernet chip n rj45 connections.therefor the tcp/ip protocols needed will be taken care of..
nw i need to program my controller using c language in a way that i can access my sql server 2005 on a remote machine...Also im trying to find out if keil compiler supports vc++, since i know that sql can be connected using this language...
plz reply...

anu john
Newbie Poster
5 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

So could you for example write a C program on another PC which connects to your SQL server?

Prototyping your ideas on a PC first will save you a hell of a lot of time.

Something simple, like login, retrieve a record, logout.

Since you've stated that you're only a beginner, this is going to be a lot of hard work.

I'm also going to assume that the embedded target doesn't come with the same kind of SQL library that a PC might.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

>>Also im trying to find out if keil compiler supports vc++, since i know that sql can be connected using this language...

vc++ is NOT a computer language -- it is a compiler.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

can anyone pls send me the code to connect sqlserver to vc++

suji87
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Didn't you even bother to read this thread? No one here is going to write the code for you.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
Ye. it will be a kit with ethernet chip n rj45 connections.therefor the tcp/ip protocols needed will be taken care of.. nw i need to program my controller using c language in a way that i can access my sql server 2005 on a remote machine...Also im trying to find out if keil compiler supports vc++, since i know that sql can be connected using this language... plz reply...

Then i think most simple way to achieve this is:
1. run your own web server somewhere on net.
2. connect web server to SQL database through PHP or other methods.
3. make HTTP calls (POST/GET) from your ethernet chip to that web server.

So that is communication will be =>
your controller <-> http server <-> sql server

0x69
Junior Poster
131 posts since Apr 2010
Reputation Points: 51
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You