(I sent same request to C# list; I apologize if the lists overlap.)
Hi,
I am frustrated by the following error encountered trying to get a Web Forms
dropdown
list populated from an SQL database table. The error display is shown below
the first
dashed line. The relevant code is shown below the second dashed line. The
error
occurs during the Form_Load processing. One potential clue is that if upon
getting
the error, I click the browser Back arrow and then the browser forward
arrow, the
page displays correctly with no error message and the dropdown list is
populated
correctly.
Would be grateful if someone can help me out.
Lou
----------------------------------------------------------------------------
----
Server Error in '/pcs' Application.
General network error. Check your network documentation.
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: General network
error. Check your network documentation.
Source Error:
Line 174: SqlConnection_1.Open() ;
Line 175: this.DataSet_proj_of_user.Reset() ;
Line 176: -->
SqlDataAdapter_sel_proj_of_user.Fill( DataSet_proj_of_user ) ;
Line 177: this.ddown_proj_of_user.DataSource = DataSet_proj_of_user
;
Line 178: this.ddown_proj_of_user.DataBind() ;
Source File: c:\inetpub\wwwroot\pcs\set_user_spec.aspx.cs Line: 176
Stack Trace:
[SqlException: General network error. Check your network documentation.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +629
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(Comman
dBehavior behavior) +9
System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior) +118
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior) +102
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
pcs.set_user_spec.load_ddown_proj_of_user(Object sender, EventArgs e) in
c:\inetpub\wwwroot\pcs\set_user_spec.aspx.cs:176
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +660
Version Information: Runtime Build:1.0.2914.16; ASP.NET Build:1.0.2914.16
----------------------------------------------------------------------------
----
in declarations inside class set_user_spec:
protected System.Data.SqlClient.SqlConnection SqlConnection_1 ;
protected System.Data.SqlClient.SqlCommand
SqlCommand_sel_proj_of_user;
protected System.Data.SqlClient.SqlDataAdapter
SqlDataAdapter_sel_proj_of_user ;
protected System.Data.DataSet DataSet_proj_of_user ;
protected System.Data.SqlClient.SqlCommand
SqlCommand_sel_spec_of_user ;
protected System.Data.SqlClient.SqlDataAdapter
SqlDataAdapter_sel_spec_of_user ;
protected System.Web.UI.WebControls.DropDownList ddown_proj_of_user;
protected System.Data.DataSet DataSet_spec_of_user ;
public string str_sql_sel_proj_of_user ;
public string str_sql_connect_info ;
in Page_Init:
SqlConnection_1 = new System.Data.SqlClient.SqlConnection() ;
SqlConnection_1.ConnectionString = this.str_sql_connect_info ;
SqlCommand_sel_proj_of_user = new
System.Data.SqlClient.SqlCommand() ;
SqlCommand_sel_proj_of_user.Connection = SqlConnection_1 ;
str_sql_sel_proj_of_user
= "SELECT proj_id FROM user_level WHERE user_id = '"
+ Page_login.str_user_id + "'" ;
SqlCommand_sel_proj_of_user.CommandText = str_sql_sel_proj_of_user
;
SqlDataAdapter_sel_proj_of_user = new
System.Data.SqlClient.SqlDataAdapter() ;
SqlDataAdapter_sel_proj_of_user.SelectCommand
SqlCommand_sel_proj_of_user ;
DataSet_proj_of_user = new System.Data.DataSet() ;
in Page_Open if (! is )
SqlConnection_1.Open() ;
this.DataSet_proj_of_user.Reset() ;
SqlDataAdapter_sel_proj_of_user.Fill( DataSet_proj_of_user ) ;
this.ddown_proj_of_user.DataSource = DataSet_proj_of_user ;
this.ddown_proj_of_user.DataBind() ;
SqlConnection_1.Close() ;