D
David
Hi,
using C# asp.net 1.1
I am having a problem. If I use the code below, but have null passed as the
PostingGuid, then by the time I get to fill the dataset, I have "an object
is not set to an instance of an object". This then totally knocks out any
connection to my database for the rest of my application until I terminate
the aspnet process.
Basically, if I have a null PageGuid, then the result from my query will be
empty (not sure if it is null).
If I wrap an if statement around the whole thing (below DS and above return
DS) checking for PostingGuid null, I don't have a problem, but I feel that
this is a hack rather than a fix. Also, there could be a case where
PostingGuid is not null but the return from the database is still empty (or
null)
public DataSet PagePropertiesRead(string PostingGuid)
{
DataSet DS = new DataSet();
DataAccessLayer.ProviderFactory DL = new
DataAccessLayer.ProviderFactory(DB);
string sql = string.Empty;
try
{
conn = DL.CreateConnection(ConnectionString);
conn.Open();
sql = "select * from Page where PageGuid = ? limit 0, 1"; // NOTE:
This is MySQL
cmd = DL.CreateCommand(sql, conn);
cmd = AddParameter(DL, cmd, "@PageGuid", DbType.String, PostingGuid);
DA = DL.CreateDataAdapter();
DA.SelectCommand = cmd;
DA.Fill(DS); <-- BREAKS HERE
}
catch (Exception ex)
{
string Text = ex.Message;
}
finally
{
conn.Close();
}
return DS;
}
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
using C# asp.net 1.1
I am having a problem. If I use the code below, but have null passed as the
PostingGuid, then by the time I get to fill the dataset, I have "an object
is not set to an instance of an object". This then totally knocks out any
connection to my database for the rest of my application until I terminate
the aspnet process.
Basically, if I have a null PageGuid, then the result from my query will be
empty (not sure if it is null).
If I wrap an if statement around the whole thing (below DS and above return
DS) checking for PostingGuid null, I don't have a problem, but I feel that
this is a hack rather than a fix. Also, there could be a case where
PostingGuid is not null but the return from the database is still empty (or
null)
public DataSet PagePropertiesRead(string PostingGuid)
{
DataSet DS = new DataSet();
DataAccessLayer.ProviderFactory DL = new
DataAccessLayer.ProviderFactory(DB);
string sql = string.Empty;
try
{
conn = DL.CreateConnection(ConnectionString);
conn.Open();
sql = "select * from Page where PageGuid = ? limit 0, 1"; // NOTE:
This is MySQL
cmd = DL.CreateCommand(sql, conn);
cmd = AddParameter(DL, cmd, "@PageGuid", DbType.String, PostingGuid);
DA = DL.CreateDataAdapter();
DA.SelectCommand = cmd;
DA.Fill(DS); <-- BREAKS HERE
}
catch (Exception ex)
{
string Text = ex.Message;
}
finally
{
conn.Close();
}
return DS;
}
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available