|
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 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
|
|
|
|
|
How does this answer the OP's question?
<appsettings>
<add key="string_var" value="data source=host;UID=userstring; pwd=passtring;initial Catalog=Deneme" />
</appsettings>
<connectionstrings />
Why are you not storing the connection string in the connectionStrings section? That's what it's there for
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
|
|
|
|
|
love_man001 wrote: data source=host;UID=userstring; pwd=passtring;initial Catalog=DATABASESTRING
SQL SERVER CONNECTION STRING
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 Elektrik Proje Tesisat Projesi Çizimi Illere Göre Nakliyat Firmalari Istatistik
http://www.evdenevenakliyatbul.com
|
|
|
|
|
Are you stupid, or do you just like posting random code snippets on forums?
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
|
|
|
|
|
So you are stupid. That's what I thought.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
hi all,
i have a table which contain reocords related to dates . i want to pick last 7 dates record.How can i acheive this task from Proper SQL query. Note that 7 dates does not mean to last 7 days(here it is possible that entry for particular date is missing for example sunday ).
let us consider this thing
i enter record in database table related to dates 21,22,23,24,25,26,27,28,29,30,31 january and 5 february .now i want to pick last 7 days entry. so SQL query return record related to 5 february and 31,30,29,28,27,26 January.
Thanks in advance
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Use the TOP[^] predicate in your SELECT query.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thank You Soooooooooooooo much. It works
i use following query
"select * from table1 where date1 in (select distinct top 5 date1 from table1 order by date1 desc) order by date1 "
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Great. Happy to help
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I'm having csv file which i tried inserting into sql server 2000
table through bulk insert
my bulk insert statement
Bulk Insert TableName From '\\FilePath\FileName.csv'
With ( FieldTerminator = ',',
RowTerminator = '\n'
)
While Executing the SQL Statement,
i'm getting the following error.
Bulk Insert: Unexpected end-of-file (EOF) encountered in data file.
i tried inserting through DTS it works.
but i want to do through Application How to do that.
Please Help Me..
Thanks,
Regards,
P.Prakash.
|
|
|
|
|
Just a guess, but for the final record, is there a row terminator?
|
|
|
|
|
In the CSV File
i think i'm not getting proper row terminator (\n) at the end of the file.
in that case how to proceed with bulk insert?
One more thing while importing the same csv file through dts then i'm able to import the CSV File data to the table.
but i want to do it in the applications.
pls kindly help me.
P.Prakash.
|
|
|
|
|
Hi prakash,
Check for the Extra spaces at the end of the file.If so remove those spaces and retry it.
|
|
|
|
|
Hi
I have permission to a databae that is replicated.. i want to have a trigger on that database table.. is it possible? will the update/insert trigger will work.? my database is updated every 5 to 10 mins..
Please help me out..
Jes
|
|
|
|
|
Yes, you can put a trigger on a replicated table.
We have a table that is updated via replication approximately every 15 minutes; there is a trigger on the table for inserts to create a subset of the data in a table in another database.
Hope that answers your question.
Tim
|
|
|
|
|
Thank you....
Can i have sample of trigger..
i am using code like this:
CREATE TRIGGER test AFTER INSERT ON temp
FOR EACH ROW BEGIN
INSERT INTO table1 SET fld1 = NEW.fld1;
INSERT INTO table1 SET fld2 = NEW.fld2;
INSERT INTO table1 SET fld3 = NEW.fld3;
END;
will this work...??
|
|
|
|
|
To be perfectly honest, I have no idea...
I didn't write the trigger on our table; I just maintain the app now.
My best advice would be: try it and see what happens.
Tim
|
|
|
|
|
thanx for quick response..
Will the error in trigger affet the original table data insertion..??
|
|
|
|