I think my previous post was not clear enough. Here is some code to explain
So in the GUI I think there is some issue because my datagrid isnt filled at all... :-(
Please quick help?
GUI
+++
PersonBLL _localpers = null;
DataSet _localds = null;
private void button1_Click_1(object sender, EventArgs e)
{
try
{
_localds = new DataSet("GeneralInfo");
_localds = PersonBLL.GetAddressesFromPerson(textBoxBranchName.Text);
dataGridViewAddresses.DataSource = _localds.Tables["Addresses"];
dataGridViewAddresses.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Person",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
BLL
+++
public static DataSet GetAddressesFromPerson(string name)
{
try
{
return PersonDAL.GetAddressesFromPerson(name);
}
catch (BranchDALException ex)
{
throw new PersonBLLException(ex.Message);
}
catch (Exception ex)
{
throw new PersonBLLException(ex.Message);
}
}
DAL
+++
public static DateSet GetAddressesFromPerson(string name)
{
try
{
int persid = PersonDAL.GetPersonID(Name);
string sql = "SELECT * FROM ADDRESS WHERE PersonId=@persid";
CommandParameterList localparams = new CommandParameterList();
localparams.Add(new CommandParameter("@persid", persid, DbParameterTypes.Int32, ParameterDirection.Input));
localDAC.LocalParameters = localparams;
return localDAC.ExecuteDS(sql, AssignmentTypes.SqlStatement, "Addresses");
}
catch (SQLDacException ex)
{
throw new PersonDALException(ex.Message);
}
catch (Exception ex)
{
throw new PersonDALException(ex.Message);
}
}
Loading
Blocked AccountPosted Nov 26, 2012, 5:49 AM
Put the Break Point and check your dataset( _localds ) have data or not and what table names it have. Because you are assigning datasource which has table name "Addresses"
so make sure your dataset containing this table.
otherwise you can write
dataGridViewAddresses.DataSource = _localds.Tables[0];