Greetings. I'm fairly new to C# and .NET so I'm hoping someone can shed some light on what I'm doing wrong here. I've googled the error message and understand what is causing the problem, I just can't see it in my code. I honestly do not see which object I'm not instantiating that is causing this error to be raised (well, it's obviously the dataset, but I've instantiated that so I don't get why it's triggering this error).
I've got a select list on a form that I'm trying to populate. The results are returned as a refCursor from an Oracle stored procedure.
However, when I try to fill the dataset I get the following error:
System.NullReferenceException: Object reference not set to an instance of an object. at research.searchGrants.spFillLocation()
The code is below:
try
{
dbConn = new OracleConnection(strLogin);
dbConn.Open();
strSQL = strSchema + "PKGSEARCH_PUBLIC.GRANT_LOCN_LIST";
dbCmd = new OracleCommand(strSQL);
dbCmd.Connection = dbConn;
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.Parameters.Add(new OracleParameter("oLOCN_LIST", OracleType.Cursor)).Direction = ParameterDirection.Output;
dbAdp = new OracleDataAdapter();
dbAdp.SelectCommand = dbCmd;
DataSet ds = new DataSet();
dbAdp.Fill(ds);
lstGrantingAgency.DataTextField = "ftvlocn_title";
lstGrantingAgency.DataValueField = "ftvlocn_title";
lstGrantingAgency.DataSource = ds.Tables[0].DefaultView;
lstGrantingAgency.DataBind();
dbConn.Close();
dbConn.Dispose();
dbCmd.Dispose();
}
catch (Exception expGen)
{
lblError.Text = expGen.ToString();
}
Can anyone point me in the right direction to identify the problem here?
As I said I'm new to C# and .NET so any assistance is very much appreciated.
Cheers and thanks in advance,
Pablo
I've got a select list on a form that I'm trying to populate. The results are returned as a refCursor from an Oracle stored procedure.
However, when I try to fill the dataset I get the following error:
System.NullReferenceException: Object reference not set to an instance of an object. at research.searchGrants.spFillLocation()
The code is below:
try
{
dbConn = new OracleConnection(strLogin);
dbConn.Open();
strSQL = strSchema + "PKGSEARCH_PUBLIC.GRANT_LOCN_LIST";
dbCmd = new OracleCommand(strSQL);
dbCmd.Connection = dbConn;
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.Parameters.Add(new OracleParameter("oLOCN_LIST", OracleType.Cursor)).Direction = ParameterDirection.Output;
dbAdp = new OracleDataAdapter();
dbAdp.SelectCommand = dbCmd;
DataSet ds = new DataSet();
dbAdp.Fill(ds);
lstGrantingAgency.DataTextField = "ftvlocn_title";
lstGrantingAgency.DataValueField = "ftvlocn_title";
lstGrantingAgency.DataSource = ds.Tables[0].DefaultView;
lstGrantingAgency.DataBind();
dbConn.Close();
dbConn.Dispose();
dbCmd.Dispose();
}
catch (Exception expGen)
{
lblError.Text = expGen.ToString();
}
Can anyone point me in the right direction to identify the problem here?
As I said I'm new to C# and .NET so any assistance is very much appreciated.
Cheers and thanks in advance,
Pablo