Sunday, March 25, 2012

Adding a Connection in Visual C++ 2005 Express

I am new to SQL Server 2005 and Visual C++ 2005 Express.

When I try and add a connection in Visual C++:

DataSource: SQL Server Database File

File Name: c:\.......file.mdf

Windows Authentication

I get the following message:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under default settings SQL Server does not allow remote connections. (provider: Share Memeory Provider, error:36 - The Shared Memory dll used to connect to SQL Server 2000 was not found)

Any ideas?

heimdaloz wrote:

I am new to SQL Server 2005 and Visual C++ 2005 Express.

When I try and add a connection in Visual C++:

DataSource: SQL Server Database File

File Name: c:\.......file.mdf

Windows Authentication

I get the following message:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under default settings SQL Server does not allow remote connections. (provider: Share Memeory Provider, error:36 - The Shared Memory dll used to connect to SQL Server 2000 was not found)

Any ideas?

Try this:

in MFC - Visual C++

CDatabase dbData;

CString szConectSql;

szConectSql = "ODBC; DSN=.SQL Server Database File; UID=sa; PWD=pwd_sa(Your_pwd_sa); DATABASE=name_of_database_you";

dbData.Open(szConectSql);

dbData.Close();

In MFC is OK!

|||

heimdaloz wrote:

I am new to SQL Server 2005 and Visual C++ 2005 Express.

When I try and add a connection in Visual C++:

DataSource: SQL Server Database File

File Name: c:\.......file.mdf

Windows Authentication

I get the following message:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under default settings SQL Server does not allow remote connections. (provider: Share Memeory Provider, error:36 - The Shared Memory dll used to connect to SQL Server 2000 was not found)

Any ideas?

Try this:

in MFC - Visual C++

CDatabase dbData;

CString szConectSql;

szConectSql = "ODBC; DSN=.SQL Server Database File; UID=sa; PWD=pwd_sa(Your_pwd_sa); DATABASE=name_of_database_you";

dbData.Open(szConectSql);

dbData.Close();

In MFC is OK!

|||

The error above sometimes happens when the instance name is incorrect, and the SqlClient provider infers that it is connecting to a SQL Server 2000 (even if none is installed).

Was the SQL Express installed as a named instance named "SQLEXPRESS" (which is the default case)?

You can verify this by opening a command windo and run

net start | findstr -i "sql"

You can verify the instance name used by the opening the "Advanced" tab in the "Add Connection" window.

It should match the instance name of the installed SQL Express.

|||I'm having the same problem connecting to SQL Server 2005 Express.

C:\net start | findstr -i "sql"
PostgreSQL Database Server 8.1
SQL Server (SQLEXPRESS)

/////////////////////////////////////////////////////////////////////

CDatabase dbDateServ;

dbDateServ.Open("ODBC; DSN=MyDSN; UID=myuid; PWD=mypass; DATABASE=mydatabase");

How do I determine the following:
1) How do I determine what the DSN is?
2) How do I determine what my UID is?
3 )How do I determine what my PWD is (or how to set it)?
4) Example database I can use within SQL Server 2005 express?

No comments:

Post a Comment