Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 SQL and Visual C++

Author  Topic 

psm1
Starting Member

6 Posts

Posted - 2010-04-03 : 11:42:39
Hi, I want to ask you, how can I connect Visual c++ with SQL server? I find some good instructions, because I found some texts, but it always write me:
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 the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)

I do everything in this text: http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/ but still nothing.

So I thing that, it is because of bad creating of my database (local). Thank you very much.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-03 : 12:29:43
http://www.connectionstrings.com/sql-server-2008



Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

psm1
Starting Member

6 Posts

Posted - 2010-04-03 : 13:52:05
Thanks, but it is still same.

I use this code, because I need just run it on my PC now:

cn->ConnectionString =  "Data Source=...\\SQLExpress;Integrated Security=true; AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQLV\DATA\\testDb.mdf;User Instance=true;";


and I use this too:

sp_configure 'user instances enabled', '1'

but still the same report.
Go to Top of Page

psm1
Starting Member

6 Posts

Posted - 2010-04-03 : 13:55:44
But I forgot to write, that I do it by sql server management studio 2008, if it can help.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-03 : 18:44:17
Is the SQL Server service started?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

psm1
Starting Member

6 Posts

Posted - 2010-04-03 : 18:49:55
Yes, SQL Server is running and Browser too. Only SQL Agent isnt runnig.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-03 : 18:51:29
So can you connect to Management Studio using Hostname\SQLExpress, where Hostname is the name of your computer?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

psm1
Starting Member

6 Posts

Posted - 2010-04-04 : 07:46:07
Yes, I can connect to Management studio in this way.
Go to Top of Page

psm1
Starting Member

6 Posts

Posted - 2010-04-04 : 08:45:51
Today I tried to connect and it failed. I didnt any changes yesterday, so I decide to use Oracle, because I have soft nerves. I dont understand it.
Go to Top of Page
   

- Advertisement -