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. Database & SysAdmin
  3. Database
  4. ASP .Net 2.0 and connect to Sql Server 2000

ASP .Net 2.0 and connect to Sql Server 2000

Scheduled Pinned Locked Moved Database
databasecsharpasp-netsql-serversysadmin
12 Posts 4 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.
  • R Offline
    R Offline
    reza toorani
    wrote on last edited by
    #1

    Hi I created ASP.NET 2.0 web application that uses SQL Server 2000 database and it works perfectly when website was in the runtime mode. Then I publised application on production server. I received the error: 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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Why it thinks I am trying to connect to SQL Server 2005 ? There is no any 2005 server on server! This is my connection string: Server=servername;Database=SOX;User ID=userxxx;Password=******;

    L P 2 Replies Last reply
    0
    • R reza toorani

      Hi I created ASP.NET 2.0 web application that uses SQL Server 2000 database and it works perfectly when website was in the runtime mode. Then I publised application on production server. I received the error: 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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Why it thinks I am trying to connect to SQL Server 2005 ? There is no any 2005 server on server! This is my connection string: Server=servername;Database=SOX;User ID=userxxx;Password=******;

      L Offline
      L Offline
      love_man001
      wrote on last edited by
      #2

      developer by senol my home page http://www.evdenevenakliyatbul.com ********************************************************* this.Web.comfig code //////////////////////////////////////////////////////// <?xml version="1.0"?> <!-- Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in \Windows\Microsoft.Net\Framework\v2.x\Config --> <configuration> <appSettings> <add key="string_var" value="data source=host;UID=userstring; pwd=passtring;initial Catalog=Deneme"/> </appSettings> <connectionStrings/> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="true"/> <!-- The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <authentication mode="Windows"/> <!-- The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> </system.web> </configuration> ///////////////////////////////////////////////////////////// class /////////////////////////////////////////////////////////// using System.Data.SqlClient; using System.Data; public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["string_var"]); /////////////////////////////////////////////////////////////

      Boya - Badana - Tadilat ve Tamirat Isle

      P 1 Reply Last reply
      0
      • L love_man001

        developer by senol my home page http://www.evdenevenakliyatbul.com ********************************************************* this.Web.comfig code //////////////////////////////////////////////////////// <?xml version="1.0"?> <!-- Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in \Windows\Microsoft.Net\Framework\v2.x\Config --> <configuration> <appSettings> <add key="string_var" value="data source=host;UID=userstring; pwd=passtring;initial Catalog=Deneme"/> </appSettings> <connectionStrings/> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="true"/> <!-- The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <authentication mode="Windows"/> <!-- The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> </system.web> </configuration> ///////////////////////////////////////////////////////////// class /////////////////////////////////////////////////////////// using System.Data.SqlClient; using System.Data; public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["string_var"]); /////////////////////////////////////////////////////////////

        Boya - Badana - Tadilat ve Tamirat Isle

        P Offline
        P Offline
        pmarfleet
        wrote on last edited by
        #3

        How does this answer the OP's question? Why are you not storing the connection string in the connectionStrings section? That's what it's there for :wtf: Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        L 1 Reply Last reply
        0
        • P pmarfleet

          How does this answer the OP's question? Why are you not storing the connection string in the connectionStrings section? That's what it's there for :wtf: Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

          L Offline
          L Offline
          love_man001
          wrote on last edited by
          #4

          data source=host;UID=userstring; pwd=passtring;initial Catalog=DATABASESTRING SQL SERVER CONNECTION STRING

          Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin Elektrik Proje Tesisat Projesi Çizimi Illere Göre Nakliyat Firmalari Istatistik http://www.evdenevenakliyatbul.com

          P 1 Reply Last reply
          0
          • L love_man001

            data source=host;UID=userstring; pwd=passtring;initial Catalog=DATABASESTRING SQL SERVER CONNECTION STRING

            Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin Elektrik Proje Tesisat Projesi Çizimi Illere Göre Nakliyat Firmalari Istatistik http://www.evdenevenakliyatbul.com

            P Offline
            P Offline
            pmarfleet
            wrote on last edited by
            #5

            love_man001 wrote:

            data source=host;UID=userstring; pwd=passtring;initial Catalog=DATABASESTRING SQL SERVER CONNECTION STRING

            :confused: Do you not understand? The connectionStrings section was introduced in .NET 2.0 for storing connection strings. No one puts connection strings in appSettings any more. I suggest you do some reading and learn how to use it.

            Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

            L 1 Reply Last reply
            0
            • P pmarfleet

              love_man001 wrote:

              data source=host;UID=userstring; pwd=passtring;initial Catalog=DATABASESTRING SQL SERVER CONNECTION STRING

              :confused: Do you not understand? The connectionStrings section was introduced in .NET 2.0 for storing connection strings. No one puts connection strings in appSettings any more. I suggest you do some reading and learn how to use it.

              Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

              L Offline
              L Offline
              love_man001
              wrote on last edited by
              #6

              using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; /// <summary> /// Summary description for VeriTabani /// </summary> public class VeriTabani { public VeriTabani() { // // TODO: Add constructor logic here // } public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["Baglanti"]); public static DataView DV_Sehirler() //ZOR OLAN { sqlBaglanti.Open(); SqlCommand sqlKomut = new SqlCommand("Select * from tbl_sehir", sqlBaglanti); SqlDataReader sqlSatirOkuyucu = sqlKomut.ExecuteReader(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.Columns.Add("sehir_id",typeof(Int32)); dt.Columns.Add("sehir", typeof(string)); DataRow dr; while (sqlSatirOkuyucu.Read()) { dr = dt.NewRow(); dr["sehir_id"] = sqlSatirOkuyucu["sehir_id"].ToString(); dr["sehir"] = sqlSatirOkuyucu["sehir"].ToString(); dt.Rows.Add(dr); } ds.Tables.Add(dt); sqlBaglanti.Close(); return ds.Tables[0].DefaultView; } public static DataView DV_SehirSonuc() { SqlDataAdapter sqlAdapter = new SqlDataAdapter("Select * from tbl_sehir", sqlBaglanti); DataSet ds = new DataSet(); sqlAdapter.Fill(ds); sqlBaglanti.Close(); return ds.Tables[0].DefaultView; } public static DataView DV_Sonuc(string sql) { SqlDataAdapter sqlAdapter = new SqlDataAdapter(sql, sqlBaglanti); DataSet ds = new DataSet(); sqlAdapter.Fill(ds); sqlBaglanti.Close(); return ds.Tables[0].DefaultView; } public static void Sorgu_Calistir(string sql) { SqlCommand sqlCommand = new SqlCommand(sql, sqlBaglanti); if (sqlCommand.Connection.State == ConnectionState.Closed) { sqlBaglanti.Open(); } sqlCommand.ExecuteNonQuery(); sqlBaglanti.Close(); } }

              Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin

              P 1 Reply Last reply
              0
              • L love_man001

                using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; /// <summary> /// Summary description for VeriTabani /// </summary> public class VeriTabani { public VeriTabani() { // // TODO: Add constructor logic here // } public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["Baglanti"]); public static DataView DV_Sehirler() //ZOR OLAN { sqlBaglanti.Open(); SqlCommand sqlKomut = new SqlCommand("Select * from tbl_sehir", sqlBaglanti); SqlDataReader sqlSatirOkuyucu = sqlKomut.ExecuteReader(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.Columns.Add("sehir_id",typeof(Int32)); dt.Columns.Add("sehir", typeof(string)); DataRow dr; while (sqlSatirOkuyucu.Read()) { dr = dt.NewRow(); dr["sehir_id"] = sqlSatirOkuyucu["sehir_id"].ToString(); dr["sehir"] = sqlSatirOkuyucu["sehir"].ToString(); dt.Rows.Add(dr); } ds.Tables.Add(dt); sqlBaglanti.Close(); return ds.Tables[0].DefaultView; } public static DataView DV_SehirSonuc() { SqlDataAdapter sqlAdapter = new SqlDataAdapter("Select * from tbl_sehir", sqlBaglanti); DataSet ds = new DataSet(); sqlAdapter.Fill(ds); sqlBaglanti.Close(); return ds.Tables[0].DefaultView; } public static DataView DV_Sonuc(string sql) { SqlDataAdapter sqlAdapter = new SqlDataAdapter(sql, sqlBaglanti); DataSet ds = new DataSet(); sqlAdapter.Fill(ds); sqlBaglanti.Close(); return ds.Tables[0].DefaultView; } public static void Sorgu_Calistir(string sql) { SqlCommand sqlCommand = new SqlCommand(sql, sqlBaglanti); if (sqlCommand.Connection.State == ConnectionState.Closed) { sqlBaglanti.Open(); } sqlCommand.ExecuteNonQuery(); sqlBaglanti.Close(); } }

                Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin

                P Offline
                P Offline
                pmarfleet
                wrote on last edited by
                #7

                Are you stupid, or do you just like posting random code snippets on forums? :suss:

                Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                L 1 Reply Last reply
                0
                • P pmarfleet

                  Are you stupid, or do you just like posting random code snippets on forums? :suss:

                  Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                  L Offline
                  L Offline
                  love_man001
                  wrote on last edited by
                  #8

                  public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["Baglanti"]);

                  Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin Elektrik Proje Tesisat Projesi Çizimi Illere Göre Nakliyat Firmalari Istatistik http://www.evdenevenakliyatbul.com

                  P I 2 Replies Last reply
                  0
                  • L love_man001

                    public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["Baglanti"]);

                    Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin Elektrik Proje Tesisat Projesi Çizimi Illere Göre Nakliyat Firmalari Istatistik http://www.evdenevenakliyatbul.com

                    P Offline
                    P Offline
                    pmarfleet
                    wrote on last edited by
                    #9

                    So you are stupid. That's what I thought. :rolleyes:

                    Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                    1 Reply Last reply
                    0
                    • L love_man001

                      public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["Baglanti"]);

                      Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin Elektrik Proje Tesisat Projesi Çizimi Illere Göre Nakliyat Firmalari Istatistik http://www.evdenevenakliyatbul.com

                      I Offline
                      I Offline
                      imsathy
                      wrote on last edited by
                      #10

                      love_man001 wrote:

                      <appSettings> <add key="string_var" value="data source=host;UID=userstring; pwd=passtring;initial Catalog=Deneme"/> </appSettings> --------- >>>>>> <connectionStrings/> <<<<<<----------- (this is where you connection string should come ....)

                      Did you get OP's point atleast now

                      Sathy

                      L 1 Reply Last reply
                      0
                      • I imsathy

                        love_man001 wrote:

                        <appSettings> <add key="string_var" value="data source=host;UID=userstring; pwd=passtring;initial Catalog=Deneme"/> </appSettings> --------- >>>>>> <connectionStrings/> <<<<<<----------- (this is where you connection string should come ....)

                        Did you get OP's point atleast now

                        Sathy

                        L Offline
                        L Offline
                        love_man001
                        wrote on last edited by
                        #11

                        class public static SqlConnection sqlBaglanti = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["string_var"]);

                        Boya - Badana - Tadilat ve Tamirat Isleri Bir Yudum Kahve Molasi (Coffee) Dügün Nisan ve Gelinlik (wedding) Google Reklamlarinizi Sadece Siz Yönetin Elektrik Proje Tesisat Projesi Çizimi Illere Göre Nakliyat Firmalari Istatistik http://www.evdenevenakliyatbul.com

                        1 Reply Last reply
                        0
                        • R reza toorani

                          Hi I created ASP.NET 2.0 web application that uses SQL Server 2000 database and it works perfectly when website was in the runtime mode. Then I publised application on production server. I received the error: 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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Why it thinks I am trying to connect to SQL Server 2005 ? There is no any 2005 server on server! This is my connection string: Server=servername;Database=SOX;User ID=userxxx;Password=******;

                          P Offline
                          P Offline
                          pmarfleet
                          wrote on last edited by
                          #12

                          Plenty of information relating to your problem can be found if you use Google[^].

                          Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                          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