Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

MS Sql server connection to a desktop c++ program

hi,
i am a new bie to this forum..
i amworking on c++ project..
now the need has come to connect to MSSQL by c++ desktop application
so is it possible..
if so how and which book torefer for this
very urgent plz help
thanks
geeta
[281 byte] By [geeta_tr] at [2007-11-11 7:24:30]
# 1 Re: MS Sql server connection to a desktop c++ program
I dont know -- but C++ is not a trivial database connect (compared to languages like VB that can do little else). You will need some third party library, and as you said, a book on how to use it.
jonnin at 2007-11-11 21:02:23 >
# 2 Re: MS Sql server connection to a desktop c++ program
...compared to languages like VB that can do little else
:eek: Ooh, Nasty nasty! ;-) Which side of the bed did we wake up on today, eh?

For the record, VB and VB.Net are capable of WAY more than just connecting to databases easily. For instance, when was the last time you wrote a website entirely in C++? Never, right? I thought so...Oh, you've done it? How long did it take you? Hmm... and are you sick of typing superfluous {} barckets yet? :->

The fact is that C++, or even C, is the best choice when you need as much speed as possible, or need access to low-level OS features. VB and its derivatives/descendants, IMHO, is/are best when you need rapid GUI app development, database access, powerful web apps written in one language, or some combination of the above.

With that off my chest, the technology to look at for accessing MSSQL databases from C++ is called OLEDB.

See this link: http://www.codeproject.com/database/DBDevVCOLEDB.asp for info on how to get started, using ATL.

This link: http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/adoplusoverview.aspx shows how to do it from ASP.NET, and has a sample in C++.

This link: http://support.microsoft.com/kb/q193332/ has a sample on creating OLEDB connection strings.

SQLAPI (http://www.sqlapi.com/) is a shareware library that claims to make it easy to connect to various databases; I haven't tried it, so I can't comment on it.

Finally, this: http://www.codeproject.com/database/#OLE+DB is a collection of articles and samples on programming OLEDB, which use C++ with and without ATL.

Hope that helps.

-Andrew
Andrew Cushen at 2007-11-11 21:03:19 >
# 3 Re: MS Sql server connection to a desktop c++ program
Heh sorry, I want really trying to be insulting, bad wording with no excuse except it was about 2am and I havent had any sleep in a week (so I guess I didnt wake up on either side).

Try this:
VB, Java, and the scripting languages are much 'easier' than C++ for this stuff (Lump all networking type programming here: db, web, etc).

And C++ is fine for rapid gui development if you have good tools. Borland makes this easy for certain, Visual requires some know-how.

Again, sorry everyone, smack me when I get outta line and I'll try to post only after I have slept from now on.
jonnin at 2007-11-11 21:04:28 >