Connecting SQL Server 2005 failed

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 946 Views - Last Post: 25 September 2012 - 06:00 AM Rate Topic: -----

#1 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Connecting SQL Server 2005 failed

Posted 24 September 2012 - 12:43 AM

I have a problem in connecting SQL Sever through VB.NET. When I create a connection it shows, " Connection failed. Server not found or change server to accept remote connections". Is there any setting to be changed when connecting to sqlserver. I am able to query my database through SQL server management studio but unable to connect my application to database.
Is This A Good Question/Topic? 0
  • +

Replies To: Connecting SQL Server 2005 failed

#2 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 03:51 AM

View PostSwapnilbarde007, on 24 September 2012 - 12:43 AM, said:

I have a problem in connecting SQL Sever through VB.NET. When I create a connection it shows, " Connection failed. Server not found or change server to accept remote connections". Is there any setting to be changed when connecting to sqlserver. I am able to query my database through SQL server management studio but unable to connect my application to database.

Please help
Was This Post Helpful? 0
  • +
  • -

#3 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 04:13 AM

Are you connecting to remote server, or local (on your computer)?
Was This Post Helpful? 0
  • +
  • -

#4 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 04:18 AM

local one
Was This Post Helpful? 0
  • +
  • -

#5 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 04:21 AM

There are numerous ways to fail connecting. Paste code, and describe what you are doing, and how.
Was This Post Helpful? 0
  • +
  • -

#6 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 04:37 AM

I have newly installed SQL Sever Express edition and SQL server management studio on my system. I have created a demo application in vb.net to test the SQL server connection. I have a form and a DataGridView dragged on it. I inserted following code on load event of form.

Imports System.Data
Imports System.Data.SqlClient

        Public  Class Form1

                Private Sub Form1_load(sender As Object, e As EventArgs)
                        Dim connetionString As String
                        Dim connection As SqlConnection
                        Dim command As SqlCommand
                        Dim adapter As New SqlDataAdapter()
                        Dim ds As New DataSet()
                        Dim sql As String

                        connetionString = "Data Source=SWAPNIL;Initial Catalog=MyTestDb;User ID=sa;Password="
                        sql = "SELECT * FROM tblTEST"

                        connection = New SqlConnection(connetionString)

                        Try
                                connection.Open()
                                command = New SqlCommand(sql, connection)
                                adapter.SelectCommand = command
                                adapter.Fill(ds)
              
                                connection.Close()

                                DataGridView1.DataSource=Ds.Tables(0)
                        Catch ex As Exception
                                MessageBox.Show("Can not open connection ! ")
                        End Try
                End Sub
        End Class
End Namespace



Was This Post Helpful? 0
  • +
  • -

#7 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 05:32 AM

Try using SqlConnectionStringBuilder class, so you can pinpoint what exactly isn't working.
Was This Post Helpful? 0
  • +
  • -

#8 hemantwithu  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 30
  • Joined: 18-October 11

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 05:32 AM

View PostSwapnilbarde007, on 24 September 2012 - 05:07 PM, said:

I have newly installed SQL Sever Express edition and SQL server management studio on my system. I have created a demo application in vb.net to test the SQL server connection. I have a form and a DataGridView dragged on it. I inserted following code on load event of form.

Imports System.Data
Imports System.Data.SqlClient

        Public  Class Form1

                Private Sub Form1_load(sender As Object, e As EventArgs)
                        Dim connetionString As String
                        Dim connection As SqlConnection
                        Dim command As SqlCommand
                        Dim adapter As New SqlDataAdapter()
                        Dim ds As New DataSet()
                        Dim sql As String

                        connetionString = "Data Source=SWAPNIL;Initial Catalog=MyTestDb;User ID=sa;Password="
                        sql = "SELECT * FROM tblTEST"

                        connection = New SqlConnection(connetionString)

                        Try
                                connection.Open()
                                command = New SqlCommand(sql, connection)
                                adapter.SelectCommand = command
                                adapter.Fill(ds)
              
                                connection.Close()

                                DataGridView1.DataSource=Ds.Tables(0)
                        Catch ex As Exception
                                MessageBox.Show("Can not open connection ! ")
                        End Try
                End Sub
        End Class
End Namespace





I think you are missing some parameters in the Connection String.Please look at you are missing Password.If you want to get the Correct Connection String try to connect to your database in VS 2010 or 2008 using Server Explorer.After It is Connected Successfully right click on the DB in Server Explorer where you will find the Properties Click on it.You will get the Correct Connection String.

Try this and let me know :-)
Was This Post Helpful? 0
  • +
  • -

#9 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 07:32 AM

When I am going to connect it through server explorer it is showing the same message. Server not found or make your server to accept remote connections" something like that. My server name is "SWPNIL". I am using SQL server authentication. its user name is 'sa' and password is blank. When I am connecting through server explorere, it is not showing the name of server in dialog box...
Was This Post Helpful? 0
  • +
  • -

#10 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Connecting SQL Server 2005 failed

Posted 24 September 2012 - 07:36 AM

Try adding ; in your connectionString after Password=, so it will look like: connetionString = "Data Source=SWAPNIL;Initial Catalog=MyTestDb;User ID=sa;Password=;"

Edit: is your server SWAPNIL or SWPNIL (notice the missing A)?

This post has been edited by lucky3: 24 September 2012 - 07:37 AM

Was This Post Helpful? 0
  • +
  • -

#11 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Re: Connecting SQL Server 2005 failed

Posted 25 September 2012 - 04:04 AM

Hi. my problem is same like this. It is unable to find the server not only in code but in server explorer window also. Ignore the code behind in image

Attached image(s)

  • Attached Image

This post has been edited by Swapnilbarde007: 25 September 2012 - 04:06 AM

Was This Post Helpful? 0
  • +
  • -

#12 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,913
  • Joined: 25-September 09

Re: Connecting SQL Server 2005 failed

Posted 25 September 2012 - 05:02 AM

You might want to take a look at some of these links. There are a few different scenerios that may cause this.

With it not working in Server Explorer, it could be the instance name is not matching in VS. Also, have you downloaded SQL Server Management Express Studio and installed it. If so, can you access it from there?

This post has been edited by CharlieMay: 25 September 2012 - 05:05 AM

Was This Post Helpful? 0
  • +
  • -

#13 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Re: Connecting SQL Server 2005 failed

Posted 25 September 2012 - 05:18 AM

yeah I have SQL server management studio installed on my pc. I am able to query that too from mgmnt studio. But when I am going to create new connection at design time, it shows the above error. In addtion to that I have XAMPP server installed on my PC. Does it affecting this?
Was This Post Helpful? 0
  • +
  • -

#14 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Connecting SQL Server 2005 failed

Posted 25 September 2012 - 05:29 AM

Quote

In addtion to that I have XAMPP server installed on my PC. Does it affecting this?


Sure can, and probably is. You need to find out on what port your IIS is running, and where XAMPP. In your browser enter localhost:80 and see what it will show. If it's xampp, than you have IIS on other port.
Was This Post Helpful? 0
  • +
  • -

#15 Swapnilbarde007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 32
  • Joined: 20-September 12

Re: Connecting SQL Server 2005 failed

Posted 25 September 2012 - 05:44 AM

On 80 Port it is XAMPP, So what should I do now. Shall I uninstall XAMPP?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2