SQL and VC.Net ?

  • Thread starter Thread starter Gorgo
  • Start date Start date
G

Gorgo

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.
 
Gorgo said:
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
 
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
 
Gorgo said:
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.

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
 
Gorgo said:
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
 
Back
Top