HI,m getting the following error wen running my asp.net web page :-
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
i have checked my server, its running properly,my Named pipes is enabled but still m not able 2 figure out wer m i going wrong
the following iz my code for the page,wer i want the data in the DB 2 b displayed in my GridView :
using System.Data.SqlClient;
public partial class products : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string Sel = "Select * from ItemTable";
SqlConnection Con = new SqlConnection();
Con.ConnectionString = "Server=deepti;Database=Database.mdf;Integrated Security=SSPI;";
SqlCommand cmd = new SqlCommand(Sel, Con);
Con.Open();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("product_id", typeof(int)));
dt.Columns.Add(new DataColumn("product_name", typeof(string)));
dt.Columns.Add(new DataColumn("unit_price", typeof(float)));
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
DataRow dr = dt.NewRow();
dr["product_id"] = Convert.ToInt32(reader["product_id"]);
dr["product_name"] = reader["product_name"];
dr["unit_price"] = Convert.ToDecimal(reader["unit_price"]);
dt.Rows.Add(dr);
}
Con.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
it is showing the error at Con.Open();
m using VS 2008 and MS SQL SERVER 2005 as backend.......pls help me bcaz m trying 2 solve da problem since 2 weeks...............pls help
Bookmarks