How do I connect to SQL Server using C#?

Let’s learn how do I connect to SQL Server using C#. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

SqlConnection in C#

In VB.NET I can use: Protected Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("Active").ConnectionString) However, when I do the following in C#: protected SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings("conn")); I get the error: The name 'ConfigurationManager' does not exist in the current context Then if I change it to: protected SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings...

Answer:

Try like this: protected SqlConnection conn = new SqlConnection( ConfigurationManager.ConnectionStrings...

Read more

Curt at Stack Overflow Mark as irrelevant Undo

Other solutions

How to connect sql server 2005 by using windows authentication from a client computer to a server?

I am a beginner of sql. I try to connect from my labtop (XP home) to my office server (server 2003) to access the database in the sql express. I am using Server Management Studio Express in my laptop, and using windows authentication, and connect to...

Answer:

Windows Authentication in this case implies that you're going to pass on whatever you're logged into...

Read more

wyeechen at Yahoo! Answers Mark as irrelevant Undo

Answer:

Well.... SQL Server does allow TCP/IP connections (default port 1433 if it's enabled), and there are...

Read more

Jon the human at Answerbag.com Mark as irrelevant Undo

Answer:

You'll need JDBC driver for SQL Server. You can download Microsoft's driver at - Microsoft JDBC Driver...

Read more

Nayan Shah at Quora Mark as irrelevant Undo

Unable to connect to SQL Server 2000 from a Linux machine using DataDirect?

When I try to connect to SQL Server 2000 running on a Windows 2003 Server from a Linux machine, I get the following error SQLConnect: Retrying Connect. SQLSTATE = 0 NATIVE ERROR = 4060 '. Login fails.ct][ODBC SQL Server Driver][SQL Server]Cannot open...

Answer:

sorry man

Read more

sawmek at Yahoo! Answers Mark as irrelevant Undo

Answer:

There are many options available. I'd like to share a few one. 1. Make a web service that process a...

Read more

Shail Shah at Quora Mark as irrelevant Undo

Answer:

I am not a Ruby programmer, but a little bit of searching found this set of examples. You want the Trusted...

Read more

Grant Fritchey at Quora Mark as irrelevant Undo

How do i connect to server on Microsoft SQL Server 2005?

I have just installed Microsoft SQL Server 2005. When I start the Server Management Studio, it displays a "Connect to Server" dialog box. I have tried my best to connect to the serevr, but i dont know which server the programming is asking...

Answer:

When you installed SQL 2005, did you make sure to set up the local database? When installing, you can...

Read more

Psybuck at Yahoo! Answers Mark as irrelevant Undo

Any tutorials for using C++ to connect Microsoft SQL?

I'm using Microsoft Visual C++ 6.0. I want to develop a console application which will connect to Microsoft SQL Server 2005 Express, and then display the content of a table using 'cout' How to do it? Any tutorial website address will be appreciated.

Answer:

use ADO or DAO ! You can find some useful article in c++ on http://www.intelliproject.net

Read more

cshong19... at Yahoo! Answers Mark as irrelevant Undo

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.