Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.net Cannot open connection to SQLExpress 2005

Posted on 2007-03-26
6
Medium Priority
?
440 Views
Last Modified: 2013-11-26
Hello.  I am having problems finding out why I cannot open a connection to my local SQLExpress instance from a vb.net form.  I have looked all over the internet, but nothing I have tried works.  Can anyone offer help?  Thanks!!
Here is my code...it bombs at the last line where the connection is opened.

        Dim ConnStr As String = "Server=localhost;DataBase=TableDining;User Id=myName;Password=pwd@1!"
        Dim sqlConnection As New Data.SqlClient.SqlConnection(ConnStr)
        Dim strSQL As String = "SELECT * FROM table WHERE (PIN = 1111)"
        Dim cmd As New Data.SqlClient.SqlCommand(strSQL, sqlConnection)
        cmd.CommandType = CommandType.Text
        cmd.Connection.Open()
     
0
Comment
Question by:josh261
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 25

Expert Comment

by:dstanley9
ID: 18793308
what error do you get?  connection strings can be cae-sensitive, so try

Dim ConnStr As String = "Server=localhost;Database=TableDining;User ID=myName;Password=pwd@1!"

(notice the change to Database and User ID)
0
 

Author Comment

by:josh261
ID: 18793399
Thanks for the quick response!!

I tried what you suggested and still get the same error.  Here's the error message I get:

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.
0
 
LVL 25

Expert Comment

by:dstanley9
ID: 18793427
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:josh261
ID: 18794530
Great article!!

I tried all of the things it said...and thought it should work but didn't.  

One of the suggestions is made when finished was to use the command prompt utility OSQL to simulate a remote connection client.  OSQL connected with no problems.

Could it be something with Visual Studio or the vb.net code?
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 2000 total points
ID: 18794626
Can you create a Data Connection to the instance in Server Explorer?  If you can, look at the properties of the connection to get your connection string.
0
 

Author Comment

by:josh261
ID: 18794712
That worked.  I just needed to add Data Source=localhost\sqlexpress in the connections string.

Thanks for your help!  You  rock!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question