I have a class that works fine using the SQLDataReader but when I try and duplicate the process using a Dataset instead of a SQLDataReader it returnsa a null value.
This is the code for the Method to return a datareader
public
SqlDataReader GetOrgID(){
Singleton s1 =Singleton.Instance();
Guid uuid;
uuid =
newGuid(s1.User_id);SqlConnection con =newSqlConnection(conString);
string selectString ="Select OrgID From aspnet_OrgNames Where UserID = @.UserID";
SqlCommand cmd =newSqlCommand(selectString, con);
cmd.Parameters.Add(
"@.UserID",SqlDbType.UniqueIdentifier, 16).Value = uuid;
con.Open();
SqlDataReader dtr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return dtr;
This is the code trying to accomplish the same thing with a Dataset instead.
publicDataSet organID(DataSet dataset)
{
Singleton s1 =Singleton.Instance();
Guid uuid;
uuid =
newGuid(s1.User_id);string queryString ="Select OrgID From aspnet_OrgNames Where UserID = @.UserID";
SqlConnection con =newSqlConnection(conString);
SqlCommand cmd =newSqlCommand(queryString, con);
cmd.Parameters.Add(
"@.UserID",SqlDbType.UniqueIdentifier, 16).Value = uuid;
SqlDataAdapter adapter =newSqlDataAdapter();
adapter.SelectCommand = cmd;
adapter.Fill(dataset);
return dataset;
}
Assume that the conString is set to a valid connection string. The Singlton passes the userid in from some code in the code behind page ...this functionality works as well.
So assume that the Guid is a valid entry..I should return a valid dataset but its null.
Additionally if I change the sql query to just be Select * From aspnet_OrgNames I still get a null value...I am assuming I am doing something wrong trying to fill the dataset.
Any help would be appreciated.
Hi,
Are you passing in a valid dataset which is not null?
include a ' dataset = new DataSet(); ' before you fill in the data and check if it works
if it does, it just means you passed in a null value...
Thank you, Thank you, Thank you!!!
VERY MUCH APPRECIATED!!!
No comments:
Post a Comment