I have a Datatable function like this
public DataTable LoadCategory(SetupCategoryBO scBO)
{
DBConnect myConnection = new DBConnect();
myConnection.connection.Open();
SqlCommand comm = new SqlCommand("ph.setup_category_proc", myConnection.connection);
comm.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
try
{
comm.Parameters.AddWithValue("@unitID", scBO.UnitID);
comm.Parameters.AddWithValue("@objectID", scBO.ObjectID);
comm.Parameters.AddWithValue("@user", scBO.UserID);
comm.Parameters.AddWithValue("@flag", scBO.Flag);
comm.Parameters.AddWithValue("@parentID", scBO.ParID);
comm.UpdatedRowSource = UpdateRowSource.None;
da.SelectCommand = comm;
da.Fill(ds, "CategoryTable");
return ds.Tables["CategoryTable"];
}
and I used this to try to get data from the datatable
DataTable dt = new DataTable();
dt = Scdal.LoadCategory(ScBo);
datagrid.Datacontext=dt;
Am i supposed to use a Sql data adapter?The datagrid shows up blank
AND the SetupCategoryBO is just used to initialize values.As far as i know The values are fine.
What am i doing wrong here?
Try this code.