aspnet to sql

Server Error in '/test/Editor' Application.

SQL Server does not exist or access denied.
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.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

Source Error:

Line 70:
Line 71: DataSet ds2 = new DataSet();
Line 72: dtAdap1.Fill(ds2, "tblNews");
Line 73:
Line 74: DataGrid1.DataSource = ds2.Tables["tblNews"].DefaultView;

Source File: e:\inetpub\wwwroot\test\editor\webform1.aspx.cs Line: 72

Stack Trace:
 
//------------------------------------------------------------------------------------
public string getConnectionStrFormWebConfig(string getConnectionStrFromWebConfig)
{
// the best way for getting state from web.config
return System.Configuration.ConfigurationSettings.AppSettings[getConnectionStrFromWebConfig];
}
//------------------------------------------------------------------------------------

private void Page_Load(object sender, System.EventArgs e)
{
TBinder();
}

void TBinder()
{

string strCon = ConfigurationSettings.AppSettings["ConnStr"];
SqlConnection wg = new SqlConnection(strCon);

SqlDataAdapter dtAdap1 = new
SqlDataAdapter("select * from tblNews ",wg);

DataSet ds2 = new DataSet();
dtAdap1.Fill(ds2, "tblNews");

DataGrid1.DataSource = ds2.Tables["tblNews"].DefaultView;
DataGrid1.DataBind();
//TextBox1.DataBind();
}


Web config:
<appSettings>
<add key="ConnStr" value="server=Localhost;Connect Timeout=30;User ID=sa;Password=XXX;database=test" />
</appSettings>
 
Back
Top