ASP .Net 2.0 and connect to Sql Server 2000
-
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=******;
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
-
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
-
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
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
-
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
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
-
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
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
-
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
-
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
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
-
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
-
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
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
-
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
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
-
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=******;