Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2004

Tip: Looking for answers? Try searching our database.

SQL and VC.Net ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gorgo - 14 Jul 2004 20:31 GMT
Hellow

I'm looking for some information about how to connect to SQL server from
vc.net application.

Does anybody know some resources , examples or somthing like that ?

big thanks for any kind of information and help

Mariusz.
Carl Daniel [VC++ MVP] - 14 Jul 2004 20:40 GMT
> Hellow
>
> I'm looking for some information about how to connect to SQL server
> from vc.net application.
>
> Does anybody know some resources , examples or somthing like that ?

How do you want to access SQL Server?  You have at least the following
choices:

1. Use the SQL server API (dblib).  Not recommended.
2. Use ODBC.
3. Use OLE-DB.
4. Use ADO.
5. Use ADO.NET

I'd suggest doing some basic research into these technologies to help
determine which is right for you.

-cd
Gorgo - 14 Jul 2004 20:49 GMT
Hello

Thank you for such a fast answer... :)

If you could write some really simple example how to connect and take some
information from SQL thru ODBC.... I think that this is the best choice for
me.

thank you again

best regards

Mariusz

> > Hellow
> >
[quoted text clipped - 16 lines]
>
> -cd
Carl Daniel [VC++ MVP] - 14 Jul 2004 22:31 GMT
> Hello
>
[quoted text clipped - 3 lines]
> some information from SQL thru ODBC.... I think that this is the best
> choice for me.

I don't speak ODBC, but you might want to ask that question on
microsoft.public.vc.mfc (MFC provides wrappers for ODBC) or on
microsoft.public.data.odbc.

-cd
William DePalo [MVP VC++] - 15 Jul 2004 00:28 GMT
> If you could write some really simple example how to connect and take some
> information from SQL thru ODBC.... I think that this is the best choice for
> me.

Carl's advice about the other groups is right on the money.

I'd go further and suggest you find a good book or use the online MSDN
reference. ODBC tries to be DBMS neutral but it doesn't try at all to shield
you from complexity and it is _huge_. It's not something you pick up in an
afternoon.

I just scanned the source to an application I wrote about a decade ago. It
appears that it takes three executable lines to connect:

HENV      hEnvironment;
HDBC      hDbConnection;
RETCODE rc;

rc = SQLAllocEnv(&hEnvironment);
rc = SQLAllocConnect(hEnvironment, &hDbConnection);
rc = SQLDriverConnect(hDBConnection, /*several more parameters go here*/);

The most important parameter in the last call is the connection string,
which for SQL Server looks something like this:

"DSN=MyODBCDataSetName;Description=MyAppDescription;UID=MyXPUserName;APP=MyA
ppName;WSID=SQLServerName;Trusted_Connection=Yes"

Regards,
Will

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.