Connection toa remote SQL server

Hi all,
   I got a problem on connecting SQL server from Visual C++ 6.0. I first open the project as a database project
Then I used 'add data connection' by right clicking on the project name...
then selected open source dialog box comes out, I selected file data source tab afterwards.I chose new and sql server afterwards. 'Create new data source' dialog box came out, I entered a new name for the source afterwards.
'Create a new data source to SQL server'
dialog box came out afterwards, In the 'Which SQL server do you want to connect to?' question, I entered the host number afterwards... I used next button without changes to 'How should SQL server verify the authenticity of login ID' and client configuration button.I pushed next button afterwards..
But the machine returned an error quoted
'Client unable to establish connection'
and 'unable to load communication module and driver has not correctly installed' resulted with ODBC SQL server dirver in brackets... Could anyone show me how to connect to the SQL server correctly... or show me some links about it??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

On the "How should SQL Server verify..." page try pressing the Client Configuration button. Make sure that the network library is set to one of types supported by your server (and your client). I'd try Named Pipes or TCP/IP if you are not sure. Here is what the help say's about this button:

Client Configuration button

Starts the Add New Network Library Configuration dialog box of the SQL Server Client Configuration.
If you specified a new name in the Server box on the first screen of the wizard, you may need to use this dialog box to add a server alias configuration entry whose name matches the name you specified in the Server box on the first screen of the ODBC wizard. The alias name must match the name you specified in the Server box. For Microsoft SQL Server, you do not usually need a server alias configuration. In most cases, the SQL Server ODBC driver can connect by using the default Net-Library and the network name supplied in the Server box on the first screen of the wizard.

"Click Client Configuration if you want the connection to use a network library other than the client’s default network library. Also click Client Configuration if the actual network address of the server must be specified for a successful connection. For example, when using the TCP/IP Net-Library you may need to specify the port and socket address of the server, or, if a SQL Server is listening on an alternate named pipe, you must specify the pipe name in the advanced entry.

For more information about configuring clients, see SQL Server Books Online."

Good Luck,

I don't know if this gonna help:

I never used a "database project" and I don't really know what it is,
but here is how to make a quick connection to SQL Server.
You can modify it afterward to better suit your needs.

First, in the control panel, select "ODBC data sources", then under
the "system DSN" tab, click add. Select your SQL Server Driver from the
list. Give a name to your data source. Select also the server
name on which is located your database.
Then we used to put a user name and his password by selecting the second
radio button choice.
You normally don't have to change anything in the other panels except
if you have more than one database on your server (and if the database
you want to connect to is not the default one)

After, in your C++ project (InitInstance of your CWinApp is a good choice)
you can connect to the database using a CDatabase member,
by using the Open method or by using OpenEx and giving the connect string like this:

CDatabase m_MyDB;

m_MyDB.OpenEx("DSN=<your DSN>;UID=<your User id>;PWD=<The pwd>",
 CDatabase::noOdbcDialog | CDatabase::useCursorLib);

that should do the job quickly

Hope it helped
whlukAuthor Commented:
what is the typical connection string
under SQL server configuration utility?

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

whlukAuthor Commented:
I sort of need some step by step (perhaps in graphical format) help!
Could you please show me some links for this?
whlukAuthor Commented:
And I need it urgently cos' my job needs me to do that.
whlukAuthor Commented:
Btw, Could you also please show me what I'm supposed to do after connection to the database after OpenEx?
whlukAuthor Commented:
To get some data out of it...
I'm just in a big hurry and every is not in proper places. So please bear with me!
Sorry for the delay, I'm presently having problems with the network here
and my internet connection suffers.

I'll give you an example.
First, set your ODBC driver like I described earlier.

Second, I'll give you an example of writing in a table. This example is using ODBC.

1. Create a new project (File new, project tab, choose MFC app wizard)
   I won't go in details here, I suppose you know the procedure. If not, ask.
   But if you don't, you will need more help on how to use Visual studio
2. Once you project is created, you create a new class derived from CRecordset,
   you will be asked to choose the ODBC source on a second dialog, it's where you
   choose the ODBC source you are supposed to have done on the first place.

3. Here is an example of how to use the recordset

   CDatabase DB;
   DB.OpenEx(NULL, CDatabase::useCursorLib);

   // Insertion of many rows without using optimization
      rs_toto  RS;      // Here is the name of the class derived from CRecordset

      RS.m_strSort = "";
      RS.m_strFilter = "ID = 123";      // You don't really need this but this speed up the
                                                      // opening of your recordset. ID is the name of my foreign key
      RS.m_pDatabase  =  &DB;
      if ( RS.Open(CRecordset::snapshot,NULL, CRecordset::none) )
         for ( int i=0; i<5000; i++ )

            RS.m_ID = 123;
            RS.m_VALUE = float(1000 + i);

            if ( !RS.Update() )
               AfxMessageBox("Update Error");

         AfxMessageBox("Open Error");

In this example, I don't have any connection string, I'll be asked to select my ODBC source at the beginning with a dialog.
whlukAuthor Commented:
So did my computer collapse... so may be coming back to you in a few days or two...sorry for any inconvenience caused...
whlukAuthor Commented:
Here comes another question
,for setting in the user name and password with the second radio choice,
Do I have to set something on the SQL Server side. like creating device, segments, database or table or the like
whlukAuthor Commented:
One of my collegues supply me a new user name and password. for example name = hello,
password = hello etc
When you are in the dlg box having 2 radio buttons, you select the one saying

How should SQL Server verify the authenticity of the login ID ?
-> With SQL Server authentication using a login ID and password entered by the user.

Then at the bottom, you enter your login ID and password.

Once your ODBC driver has been all set,
you can verify your data with MSAccess if you want to by using
this ODBC driver you've just created.

To do this, you create a new database in Access;
then, (I have a french MSAccess here, so I don't have the exact names)
in the file menu, you have a choice that should look like "external data"
with a sub menu called "Link table". Select that.
In the dialog that appears, you go in the "file type combo box" and you
select "ODBC database". In the machine data source tab,
you select the driver you've created.
At that point, I'll go by memory since I don't have any SQL Server database on my hand.
Maybe you'll have a security dialog that will ask for your "hello" pwd and uid.
You're supposed to see next a list of table from wich you can select all or only the tables
you want to see.
What all that MsAccess stuff's all about? it can help you visualize or modify the datas in your
SQL Server DB since you're linked with that DB in MSAccess. Those data's are coming directly from
that DB. Be carefull not to modify data you don't want to.
If you save that MSAccess DB, you will not have to go through all those steps again.

Now, for the C++ side, like I said earlier, you can use the Open method.
With that, when you will run, you will see a dialog that will be exactly the same as
the one having the "machine data source" tab you saw in the MSAccess path.
You will be able to select your ODBC source before continuing to run.

If you choose the OpenEx method instead, the connection string will be something like that:
Suppose you named your ODBC driver "MyDriver",
YourDBMember.OpenEx("DSN=MyDriver;UID=Hello;PWD=Hello", CDatabase::noOdbcDialog | CDatabase::useCursorLib);

I hope all these will be enough to answer your question.
I see that we don't live on the same hours, I probably answer when you are sleeping and vice-versa.
I will not be here for a couple of weeks. I'm here till 17h00 today (I'm in Quebec, Canada, so Estern time)
If you have more questions, I'll be back on january 25th.
Good luck !

PS if you have a database already created on SQL Server (and I assume that you do since your collegue gave you a user id and pwd, you don't have to do anything on that side)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
whlukAuthor Commented:
what about 'which SQL server do you want to connect to?' in the 'Create a new data source to a SQL server dialog'
is it supposed to be a host number like etc or there should be some formatted strings or the host name instead.

whlukAuthor Commented:
what is dsn in openex and where should I put the CDatabase and the related stuffs in. Onpaint...? Onclick?
whlukAuthor Commented:
ls there any way that i can view the struture or content of the database in the SQL server
whlukAuthor Commented:
Could anybody please supply me some links for complete visual c++ database programming (using MFC, ODBC, OLE DB or/and ADO)?
whlukAuthor Commented:
or books? journals? or anything
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.