Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SQL server name not found:Admin-PC\MSSQLSERVER,1433

SQL server name not found:Admin-PC\MSSQLSERVER,1433

Scheduled Pinned Locked Moved C#
csharpdatabasesql-servervisual-studiolinq
16 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tunisien86
    wrote on last edited by
    #1

    Hi guys, I develop a csharp smart device project.My code is:

    using System;
    using System.Linq;
    using System.Data.SqlServerCe;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace ModeDifféré
    {
    public partial class Form6 : Form
    {
    public Form6()
    {
    InitializeComponent();
    }

        private void comboBox1\_SelectedIndexChanged(object sender, EventArgs e)
        {
    
        }
    
        private void Form6\_Load(object sender, EventArgs e)
        {
          
            string sConnection = @"Data Source=Admin-PC\\MSSQLSERVER,1433;Initial Catalog=GMAO;User ID=sa;Password=sa;";
            string sSQL = "SELECT Nbt FROM 4BT; ";
            SqlConnection conn = new SqlConnection(sConnection);
            SqlCommand comm = new SqlCommand(sSQL, conn);
            SqlDataReader dr = null;
            try
            {
                comm.Connection.Open();
                dr = comm.ExecuteReader();
                while (dr.Read())
                    comboBox1.Items.Add(dr\[0\]);
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
    
            dr.Close();
            comm.Connection.Close();
        }
    }
    

    }

    When running this program and after turning off my Firewall(to enable all connections including TCP connections to SQL SERVER),This error appears

    Specifid SQL server name not found:Admin-PC\MSSQLSERVER,1433

    Thanks :) Notes!!! I work with: - SQL SERVER 2005 standart edition -Visual Studio 2008 entreprise edition -windows Se7en

    A S 2 Replies Last reply
    0
    • T Tunisien86

      Hi guys, I develop a csharp smart device project.My code is:

      using System;
      using System.Linq;
      using System.Data.SqlServerCe;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Data.SqlClient;
      using System.Drawing;
      using System.Text;
      using System.Windows.Forms;

      namespace ModeDifféré
      {
      public partial class Form6 : Form
      {
      public Form6()
      {
      InitializeComponent();
      }

          private void comboBox1\_SelectedIndexChanged(object sender, EventArgs e)
          {
      
          }
      
          private void Form6\_Load(object sender, EventArgs e)
          {
            
              string sConnection = @"Data Source=Admin-PC\\MSSQLSERVER,1433;Initial Catalog=GMAO;User ID=sa;Password=sa;";
              string sSQL = "SELECT Nbt FROM 4BT; ";
              SqlConnection conn = new SqlConnection(sConnection);
              SqlCommand comm = new SqlCommand(sSQL, conn);
              SqlDataReader dr = null;
              try
              {
                  comm.Connection.Open();
                  dr = comm.ExecuteReader();
                  while (dr.Read())
                      comboBox1.Items.Add(dr\[0\]);
              }
              catch (SqlException ex)
              {
                  MessageBox.Show(ex.Message);
                  return;
              }
      
              dr.Close();
              comm.Connection.Close();
          }
      }
      

      }

      When running this program and after turning off my Firewall(to enable all connections including TCP connections to SQL SERVER),This error appears

      Specifid SQL server name not found:Admin-PC\MSSQLSERVER,1433

      Thanks :) Notes!!! I work with: - SQL SERVER 2005 standart edition -Visual Studio 2008 entreprise edition -windows Se7en

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Try using the IP address instead of 'Admin-PC'.

      T 1 Reply Last reply
      0
      • A Abhinav S

        Try using the IP address instead of 'Admin-PC'.

        T Offline
        T Offline
        Tunisien86
        wrote on last edited by
        #3

        Hi, I tried like this:

        string sConnection = "Data Source=192.168.1.4,1433;Initial Catalog=GMAO;User ID=sa;Password=sa;";

        but the same error appears:Specified sql server not found or access denied Thanks

        A 1 Reply Last reply
        0
        • T Tunisien86

          Hi guys, I develop a csharp smart device project.My code is:

          using System;
          using System.Linq;
          using System.Data.SqlServerCe;
          using System.Collections.Generic;
          using System.ComponentModel;
          using System.Data;
          using System.Data.SqlClient;
          using System.Drawing;
          using System.Text;
          using System.Windows.Forms;

          namespace ModeDifféré
          {
          public partial class Form6 : Form
          {
          public Form6()
          {
          InitializeComponent();
          }

              private void comboBox1\_SelectedIndexChanged(object sender, EventArgs e)
              {
          
              }
          
              private void Form6\_Load(object sender, EventArgs e)
              {
                
                  string sConnection = @"Data Source=Admin-PC\\MSSQLSERVER,1433;Initial Catalog=GMAO;User ID=sa;Password=sa;";
                  string sSQL = "SELECT Nbt FROM 4BT; ";
                  SqlConnection conn = new SqlConnection(sConnection);
                  SqlCommand comm = new SqlCommand(sSQL, conn);
                  SqlDataReader dr = null;
                  try
                  {
                      comm.Connection.Open();
                      dr = comm.ExecuteReader();
                      while (dr.Read())
                          comboBox1.Items.Add(dr\[0\]);
                  }
                  catch (SqlException ex)
                  {
                      MessageBox.Show(ex.Message);
                      return;
                  }
          
                  dr.Close();
                  comm.Connection.Close();
              }
          }
          

          }

          When running this program and after turning off my Firewall(to enable all connections including TCP connections to SQL SERVER),This error appears

          Specifid SQL server name not found:Admin-PC\MSSQLSERVER,1433

          Thanks :) Notes!!! I work with: - SQL SERVER 2005 standart edition -Visual Studio 2008 entreprise edition -windows Se7en

          S Offline
          S Offline
          Stanciu Vlad
          wrote on last edited by
          #4

          In the connection string you specify Admin-PC\MSSQLSERVER,1433 as the server. This means the computer name is Admin-PC, the instance name is MSSQLSERVER and the port to be used is 1433. a) You should check if your sql server has an instance name. b) you sould check that the port 1433 (TCP) is not blocked by any firewalls c) You should check that the sql server instance is configured to accept network connections on the port 1433 (not dynamic port)

          I have no smart signature yet...

          T 1 Reply Last reply
          0
          • T Tunisien86

            Hi, I tried like this:

            string sConnection = "Data Source=192.168.1.4,1433;Initial Catalog=GMAO;User ID=sa;Password=sa;";

            but the same error appears:Specified sql server not found or access denied Thanks

            A Offline
            A Offline
            Abhinav S
            wrote on last edited by
            #5

            Have a look at some connection string samples here-maybe that can help.

            1 Reply Last reply
            0
            • S Stanciu Vlad

              In the connection string you specify Admin-PC\MSSQLSERVER,1433 as the server. This means the computer name is Admin-PC, the instance name is MSSQLSERVER and the port to be used is 1433. a) You should check if your sql server has an instance name. b) you sould check that the port 1433 (TCP) is not blocked by any firewalls c) You should check that the sql server instance is configured to accept network connections on the port 1433 (not dynamic port)

              I have no smart signature yet...

              T Offline
              T Offline
              Tunisien86
              wrote on last edited by
              #6

              Hi vlad, the 2 suggestions a) and c) are verified but the b),really I don't understand how to verify it. As a note,I turn off my Firewall and run my program but the same error stills. Any help will be grantful :)

              S 1 Reply Last reply
              0
              • T Tunisien86

                Hi vlad, the 2 suggestions a) and c) are verified but the b),really I don't understand how to verify it. As a note,I turn off my Firewall and run my program but the same error stills. Any help will be grantful :)

                S Offline
                S Offline
                Stanciu Vlad
                wrote on last edited by
                #7

                If the firewall is turned off then that should be ok, this means that the port is not blocked. And if all the conditions are met, then you should be able to connect to your server, but you stil can't. Try connectiong without telling the port in the connection string (something like @"Data Source=Admin-PC\MSSQLSERVER;Initial Catalog=GMAO;User ID=sa;Password=sa;"), if this stil fails, try connectiong with other applications, like the sql management studio, or visual studio in order to see if it works. If other applications work and your's fails then the problem is in the connection string (server name or instance name), else the problem is in the server configuration (like network access). By the way, what is the exact error it you get?

                I have no smart signature yet...

                T 1 Reply Last reply
                0
                • S Stanciu Vlad

                  If the firewall is turned off then that should be ok, this means that the port is not blocked. And if all the conditions are met, then you should be able to connect to your server, but you stil can't. Try connectiong without telling the port in the connection string (something like @"Data Source=Admin-PC\MSSQLSERVER;Initial Catalog=GMAO;User ID=sa;Password=sa;"), if this stil fails, try connectiong with other applications, like the sql management studio, or visual studio in order to see if it works. If other applications work and your's fails then the problem is in the connection string (server name or instance name), else the problem is in the server configuration (like network access). By the way, what is the exact error it you get?

                  I have no smart signature yet...

                  T Offline
                  T Offline
                  Tunisien86
                  wrote on last edited by
                  #8

                  Hi, I really verify many propositions but still this error annoying me a lot:

                  Specified sql server doesn't exist or access denied

                  One thing I don't understand from u last reply:else the problem is in the server configuration (like network access). I am really fed up with this error:mad: Thank u for u contribution Marwen

                  S 1 Reply Last reply
                  0
                  • T Tunisien86

                    Hi, I really verify many propositions but still this error annoying me a lot:

                    Specified sql server doesn't exist or access denied

                    One thing I don't understand from u last reply:else the problem is in the server configuration (like network access). I am really fed up with this error:mad: Thank u for u contribution Marwen

                    S Offline
                    S Offline
                    Stanciu Vlad
                    wrote on last edited by
                    #9

                    As a sugestion, drop the 1433 port from the connection string, just leave it to serverName\instanceName (Admin-PC\MSSQLSERVER) I assume you can't connect to the sql server from any other application, not just yours. If you have the sql server on the same pc with the application then the application will use named pipes for communication. If the sql server is on another pc then the application will use TCP/IP packeges for communication. If you server is on the same pc with the application then you either have the wrong server name, or the wrong instance name (which you said it is not true). If the sql server is on another pc then you haven't congiured the server for remote access. This link explains (with images) how to enable remote connections for sql server (it works for 2005 as well). Enable Remote Connection on SQL Server 2008 Express[^]

                    I have no smart signature yet...

                    T 1 Reply Last reply
                    0
                    • S Stanciu Vlad

                      As a sugestion, drop the 1433 port from the connection string, just leave it to serverName\instanceName (Admin-PC\MSSQLSERVER) I assume you can't connect to the sql server from any other application, not just yours. If you have the sql server on the same pc with the application then the application will use named pipes for communication. If the sql server is on another pc then the application will use TCP/IP packeges for communication. If you server is on the same pc with the application then you either have the wrong server name, or the wrong instance name (which you said it is not true). If the sql server is on another pc then you haven't congiured the server for remote access. This link explains (with images) how to enable remote connections for sql server (it works for 2005 as well). Enable Remote Connection on SQL Server 2008 Express[^]

                      I have no smart signature yet...

                      T Offline
                      T Offline
                      Tunisien86
                      wrote on last edited by
                      #10

                      Hi Vlad, I try without number port but doesn't work. I assume you can't connect to the sql server from any other application, not just yours?????I don't understand it. For the information given in DataSource field,when clicking on run, typing services.msc, scroll down to see list of services with name starting with sql server,I found that only the instance existing is the default one SQL Server (MSSQLSERVER)(For more clarification,see this link http://www.sqlservercentral.com/Forums/Topic918470-323-1.aspx[^]) Thanks

                      S 1 Reply Last reply
                      0
                      • T Tunisien86

                        Hi Vlad, I try without number port but doesn't work. I assume you can't connect to the sql server from any other application, not just yours?????I don't understand it. For the information given in DataSource field,when clicking on run, typing services.msc, scroll down to see list of services with name starting with sql server,I found that only the instance existing is the default one SQL Server (MSSQLSERVER)(For more clarification,see this link http://www.sqlservercentral.com/Forums/Topic918470-323-1.aspx[^]) Thanks

                        S Offline
                        S Offline
                        Stanciu Vlad
                        wrote on last edited by
                        #11

                        Tunisien86 wrote:

                        I assume you can't connect to the sql server from any other application, not just yours?????I don't understand it

                        Any other application that uses the sql server, like Management Studio, or Visual Studio are able to connect to the server? Now back to the topic, in that link you supplied, there is something like this:

                        SQL Server (MSSQLSERVER) is your default Instance.
                        SQL Server (<Instance Name>) is your named instance.

                        Default instance means that there is no named instance, so if you have that default instance installed then you don't have a named one. In shorter words, the right connection string for you is

                        string sConnection = @"Data Source=Admin-PC;Initial Catalog=GMAO;User ID=sa;Password=sa;";

                        You said in the thread on sqlservercentral that you can successfully connect to Management Studio, what is entered in login form there (like server name, username or trusted connection)?

                        I have no smart signature yet...

                        T 3 Replies Last reply
                        0
                        • S Stanciu Vlad

                          Tunisien86 wrote:

                          I assume you can't connect to the sql server from any other application, not just yours?????I don't understand it

                          Any other application that uses the sql server, like Management Studio, or Visual Studio are able to connect to the server? Now back to the topic, in that link you supplied, there is something like this:

                          SQL Server (MSSQLSERVER) is your default Instance.
                          SQL Server (<Instance Name>) is your named instance.

                          Default instance means that there is no named instance, so if you have that default instance installed then you don't have a named one. In shorter words, the right connection string for you is

                          string sConnection = @"Data Source=Admin-PC;Initial Catalog=GMAO;User ID=sa;Password=sa;";

                          You said in the thread on sqlservercentral that you can successfully connect to Management Studio, what is entered in login form there (like server name, username or trusted connection)?

                          I have no smart signature yet...

                          T Offline
                          T Offline
                          Tunisien86
                          wrote on last edited by
                          #12

                          Hi, I had all suggestions tried but still not working !!!!!!!! I am really crazy :(( Thanks

                          1 Reply Last reply
                          0
                          • S Stanciu Vlad

                            Tunisien86 wrote:

                            I assume you can't connect to the sql server from any other application, not just yours?????I don't understand it

                            Any other application that uses the sql server, like Management Studio, or Visual Studio are able to connect to the server? Now back to the topic, in that link you supplied, there is something like this:

                            SQL Server (MSSQLSERVER) is your default Instance.
                            SQL Server (<Instance Name>) is your named instance.

                            Default instance means that there is no named instance, so if you have that default instance installed then you don't have a named one. In shorter words, the right connection string for you is

                            string sConnection = @"Data Source=Admin-PC;Initial Catalog=GMAO;User ID=sa;Password=sa;";

                            You said in the thread on sqlservercentral that you can successfully connect to Management Studio, what is entered in login form there (like server name, username or trusted connection)?

                            I have no smart signature yet...

                            T Offline
                            T Offline
                            Tunisien86
                            wrote on last edited by
                            #13

                            Hi, To verify my parametres given in my connection string,I create a file .udl and I verify my connexion that is good fine and connexion works well.The problem is that the info in this file are the same that i write in my code. I wanna ask how can I use this file in my code without need of the connexion string??? Thanks

                            1 Reply Last reply
                            0
                            • S Stanciu Vlad

                              Tunisien86 wrote:

                              I assume you can't connect to the sql server from any other application, not just yours?????I don't understand it

                              Any other application that uses the sql server, like Management Studio, or Visual Studio are able to connect to the server? Now back to the topic, in that link you supplied, there is something like this:

                              SQL Server (MSSQLSERVER) is your default Instance.
                              SQL Server (<Instance Name>) is your named instance.

                              Default instance means that there is no named instance, so if you have that default instance installed then you don't have a named one. In shorter words, the right connection string for you is

                              string sConnection = @"Data Source=Admin-PC;Initial Catalog=GMAO;User ID=sa;Password=sa;";

                              You said in the thread on sqlservercentral that you can successfully connect to Management Studio, what is entered in login form there (like server name, username or trusted connection)?

                              I have no smart signature yet...

                              T Offline
                              T Offline
                              Tunisien86
                              wrote on last edited by
                              #14

                              Hi barts, Finally I depass the problem of the connexion to server by the DB File's attachment :laugh: . No exception apperas.Still now the problem of the filling of my combobox .I try with sqldataset instead of the sqlreader like this:

                              string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
                              string sSQL = "SELECT com FROM energie; ";
                              SqlConnection conn = new SqlConnection(sConnection);
                              SqlCommand comm = new SqlCommand(sSQL, conn);
                              DataSet ds = new DataSet();
                              SqlCeDataAdapter da = new SqlCeDataAdapter();
                              SqlDataReader dr = null;
                              try
                              {

                              comm.Connection.Open();
                              da.Fill(ds, "SQL Temp Table");
                              foreach(DataRow d in ds.Tables\[0\].Rows)
                              comboBox1.Items.Add(d.ToString());
                              

                              }
                              catch (SqlException ex)
                              {
                              //MessageBox.Show("connexion impossible");
                              MessageBox.Show(ex.Message);
                              return;
                              }

                              dr.Close();
                              comm.Connection.Close();
                              }

                              but nothing is added to my combobox. Thanks in all cases for u collaboration :laugh:

                              S 1 Reply Last reply
                              0
                              • T Tunisien86

                                Hi barts, Finally I depass the problem of the connexion to server by the DB File's attachment :laugh: . No exception apperas.Still now the problem of the filling of my combobox .I try with sqldataset instead of the sqlreader like this:

                                string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
                                string sSQL = "SELECT com FROM energie; ";
                                SqlConnection conn = new SqlConnection(sConnection);
                                SqlCommand comm = new SqlCommand(sSQL, conn);
                                DataSet ds = new DataSet();
                                SqlCeDataAdapter da = new SqlCeDataAdapter();
                                SqlDataReader dr = null;
                                try
                                {

                                comm.Connection.Open();
                                da.Fill(ds, "SQL Temp Table");
                                foreach(DataRow d in ds.Tables\[0\].Rows)
                                comboBox1.Items.Add(d.ToString());
                                

                                }
                                catch (SqlException ex)
                                {
                                //MessageBox.Show("connexion impossible");
                                MessageBox.Show(ex.Message);
                                return;
                                }

                                dr.Close();
                                comm.Connection.Close();
                                }

                                but nothing is added to my combobox. Thanks in all cases for u collaboration :laugh:

                                S Offline
                                S Offline
                                Stanciu Vlad
                                wrote on last edited by
                                #15

                                Hey, Glad to see you've progressed! I have a couple of commentaries: 1) 127.0.0.1 is the ip of the loopback interface, so if you use the loopback then you use no network (so this was a network problem, probably missing network connection?) 2) the data adapter da is not retriving any rows because it has no select command. You should use this line of code SqlCeDataAdapter da = new SqlCeDataAdapter(comm); 3) there is no use form the data reader dr 4) sql ce data adapter does not work with sql command or sql connection... 5) it is usefull to bind data to the combo box in order to maintain relation with your database entity. I recommend this snippet of code:

                                string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
                                string sSQL = "SELECT ID, com FROM energie";

                                SqlConnection conn = new SqlConnection(sConnection);
                                SqlCommand comm = new SqlCommand(sSQL, conn);
                                SqlDataAdapter da = new SqlDataAdapter(comm);

                                try
                                {
                                DataSet ds = new DataSet();

                                comm.Connection.Open();
                                
                                da.Fill(ds);
                                
                                comboBox1.DataSource = da.Table\[0\];
                                comboBox1.DisplayMember = "com";
                                comboBox1.ValueMember = "ID";
                                

                                }
                                catch (SqlException ex)
                                {
                                MessageBox.Show(ex.Message);
                                }
                                finally
                                {
                                comm.Connection.Close();
                                }

                                I have no smart signature yet...

                                T 1 Reply Last reply
                                0
                                • S Stanciu Vlad

                                  Hey, Glad to see you've progressed! I have a couple of commentaries: 1) 127.0.0.1 is the ip of the loopback interface, so if you use the loopback then you use no network (so this was a network problem, probably missing network connection?) 2) the data adapter da is not retriving any rows because it has no select command. You should use this line of code SqlCeDataAdapter da = new SqlCeDataAdapter(comm); 3) there is no use form the data reader dr 4) sql ce data adapter does not work with sql command or sql connection... 5) it is usefull to bind data to the combo box in order to maintain relation with your database entity. I recommend this snippet of code:

                                  string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
                                  string sSQL = "SELECT ID, com FROM energie";

                                  SqlConnection conn = new SqlConnection(sConnection);
                                  SqlCommand comm = new SqlCommand(sSQL, conn);
                                  SqlDataAdapter da = new SqlDataAdapter(comm);

                                  try
                                  {
                                  DataSet ds = new DataSet();

                                  comm.Connection.Open();
                                  
                                  da.Fill(ds);
                                  
                                  comboBox1.DataSource = da.Table\[0\];
                                  comboBox1.DisplayMember = "com";
                                  comboBox1.ValueMember = "ID";
                                  

                                  }
                                  catch (SqlException ex)
                                  {
                                  MessageBox.Show(ex.Message);
                                  }
                                  finally
                                  {
                                  comm.Connection.Close();
                                  }

                                  I have no smart signature yet...

                                  T Offline
                                  T Offline
                                  Tunisien86
                                  wrote on last edited by
                                  #16

                                  Hi, I experiment u suggestion but still my combobox wants to be always empty :( .It refuses to be filled what a strong combobox!!! Thank u

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups