Pieter Twentyeight

Pieter Twentyeight

  • NA
  • 37
  • 11.3k

DataSource for DataSet

Nov 26 2012 4:15 AM

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);
        }
}

Answers (1)