I've written a sales and inventory program in C# that makes use of SQL Server, because I've heard it functions well over LAN connections (haven't tried it yet).

I've... let's say... hardwired the my connection string into the program. I have a notepad connection.ini file that has the connection string, which goes something like this:


So, everytime I have to connect to the SQL server, I use this:

string pathCheck = Directory.GetCurrentDirectory();
                    pathCheck = pathCheck.Replace(@"\", "/");
                    pathCheck = pathCheck.Replace(@"/bin/Debug", "/App_Data/connection.ini");
                    StreamReader sr = File.OpenText(pathCheck);

                        string sql = "DELETE FROM takeoffList;";
                        SqlConnection myConn = new SqlConnection(sr.ReadLine().ToString());
                        SqlCommand myComm = new SqlCommand(sql, myConn);
                        MessageBox.Show("Item has been deleted from database.", "AIS");
                    catch (Exception ex)

The above code has no problems, whatsoever. The program works fine, but I needed Crystal Reports to finish it. So I tried to follow this page:


Now, for some reason, that method requires a Data Connection (which up to this point, I assumed I had). When opening up Server Explorer in C#, the database is not there.

So I tried to create a new database via C# (Server Explorer), if only so I can see something in my Data Connections. Then it tells me "Name Pipes Provider, error 40 - Could not open a connection to SQL Server."

At this point, I have no idea what to do, or what happened (my program still runs fine).

I have Visual Studio 2005, Sql Management Studio Express (with TCP / IP and Name Pipes set to Enabled) and I'm running on Windows 7 32-bit (with sqlservr.exe and sqlbrowser.exe exceptions in the firewall).

Could anyone please tell me what I'm doing wrong? Thanks.

Nevermind. I got it myself. :)

Now, here's what I *think* I did wrong.

When the Data Connection is asking for a Server, I clicked the dropdown list of available servers in my PC, which is, quite unimaginatively, named MY-PC.

After looking at my notepad connection string and the error regarding the instance, I simply added a "\SQLEXPRESS" to the end of the server name, so the full server name is now:


And now my database appears in the Data Connections. Yey!

If any other trouble pops up, I'll see if I can keep this thread open to post it in. I might be asked to mark this as solved.

If you got it, just mark this thread as answered. Thx in advance.