I met a problem, the error message is "Object reference not set to an instance of an object." ,which indicating the * row has this problem. I really don't understand, please help me!
Bellow is my code:
private void BindTypeData(){Thanks first!
string query = "select * from tblFacilityType";
sqlDataAdapter = new SqlDataAdapter(query,sqlConnection);
ds = new DataSet();
sqlDataAdapter.Fill(ds,"tblFacilityType");
* FacilityDataGrid.DataSource = ds.Tables["tblFacilityType"];
FacilityDataGrid.DataBind();
}
feiMake sure that sqlConnection and FacilityDataGrid are instantiated somewhere else.|||hi,jason
I've checked, it is there. But i still have the same problem!
public class __FacilityType : System.Web.UI.UserControl
{
protected DataSet ds;
protected SqlConnection sqlConnection;
protected SqlDataAdapter sqlDataAdapter;
protected SqlCommand sqlSelectCommand;
protected SqlCommand sqlInsertCommand;
protected Panel FacilityTypePanel;
protected DataGrid FacilityTypeDataGrid;
protected SqlDataReader reader;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack){
BindTypeData();
}
}
//Todo: bind data for the facility list datagrid
private void BindTypeData(){
string query = "select * from tblFacilityType";
sqlDataAdapter = new SqlDataAdapter(query,sqlConnection);
ds = new DataSet();
sqlDataAdapter.Fill(ds,"tblFacilityType");
FacilityTypeDataGrid.DataSource = ds.Tables["tblFacilityType"];
FacilityTypeDataGrid.DataBind();
}|||Where and how are u instantiating sqlConnection?
No comments:
Post a Comment