SP w/ parameter using a DAL

K

kuhrty

Hi,

I am using the enterprise DAL that I downloaded from Microsoft. I am
trying to create a data table based SP with a passed parameter but I
keep getting a null exception error. I thought it was set-up correctly
but it doesn't appear data table is being populated. The code below
is what I have written but confused on the issue. Any help or
suggestion is greatly appreciated. I am new to C# and .Net so I am
going through growing pains

Error: An unhandled exception of type 'System.NullReferenceException'
occurred in classlibrary1.dll

Mark


private void cbPyramid_SelectedIndexChanged(object sender,
System.EventArgs e)
{
DataTable dt = new DataTable();
int i;

Department dsDept = new Department(cbPyramid.Text);
dt = dsDept.Get_Dept;

cbDept.Items.Clear();

for (i = 0; i < dt.Rows.Count; i++)
{
cbDept.Items.Add(dt.Rows["Dept"]);
}
}

//Business object code
#region Private Members
private DataSet _dsDept;
#endregion

#region Public Properties

public DataTable Get_Dept
{
get { return _dsDept.Tables[0]; }
}

#endregion

#region Public Methods

public Department(string Pyramid)
{
//This will establish the database connection
Database db = DatabaseFactory.CreateDatabase("Test");
//This will allow you to call a SP and use parameters
DBCommandWrapper dbc =
db.GetStoredProcCommandWrapper("usp_Inv_GetDepartment");
dbc.AddInParameter("@pyramid", DbType.String, Pyramid);
db.ExecuteDataSet(dbc);
}

#endregion
}
 
K

kuhrty

I finally saw what happened, due to learning .Net and C# all at once I
forgot to reference the dataset.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top