3
Reply

connection with database does not open!

zeeshan akram

zeeshan akram

Jun 18 2017 1:57 AM
202
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["DBS"].ConnectionString;
SqlConnection conn = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("Select * From route", conn);
conn.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
conn.Close();
}
}
 
 
here is the error !!!

Server Error in '/' Application.

The system cannot find the file specified

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error:

Line 17:             SqlConnection conn = new SqlConnection(cs); 
Line 18:             SqlCommand cmd = new SqlCommand("Select * From route", conn); 
Line 19:             conn.Open(); 
Line 20:   
Line 21:             GridView1.DataSource = cmd.ExecuteReader();

Source File: c:\Users\ZEESHAN\Documents\Visual Studio 2013\Projects\ADOTUTS\ADOTUTS\WebForm1.aspx.cs Line: 19
 
 

Answers (3)