Hello, I'm experiencing a conflict between my DataSet.xsd and and a Sql Helper business object.
In my business object... whenever I attempt to create a new dataset (ie, DataSet ds = new DataSet()), the dataSet is being loaded with the DataSet.xsd info and not my custom object info. Is there a way I can get around this--I've bolded the problem below?
Any help would be greatly appreciated! :)
Jason
Here is my custom object code:
public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
//create a command and prepare it for execution
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
//create the DataAdapter & DataSet
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet(); // ** ds.Tables[0].TableName will be "MemberInfo" which is being pulled from DataSet.xsd) I need this DataSet to reference the custom info I am passing in, not the DataSet.xsd.
//fill the DataSet using default values for DataTable names, etc.
da.Fill(ds);
// detach the SqlParameters from the command object, so they can be used again.
cmd.Parameters.Clear();
From the code, I can see that you're using a SqlHelper class to get the command execute and return a DataSet.
Based on my experience, the SqlHelper class provided in the Data Access Application Block is only suitable to be used for an untyped DataSet. If you have your own Business Logic Layer and need to use a typed DataSet you defined, I suggest you customize your
own Data Access Layer.
You can create and fill a typed DataSet instance and return it to BLL.
Sincerely,
Kevin Yu
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Mark as Not Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Marked as answer by Kevin Yu - MSFT on Feb 23, 2007 04:01 AM
Jason Duncan
Member
413 Points
222 Posts
DataSet.xsd problems with SQLHelper business object
Feb 20, 2007 02:35 PM|LINK
Hello, I'm experiencing a conflict between my DataSet.xsd and and a Sql Helper business object.
In my business object... whenever I attempt to create a new dataset (ie, DataSet ds = new DataSet()), the dataSet is being loaded with the DataSet.xsd info and not my custom object info. Is there a way I can get around this--I've bolded the problem below? Any help would be greatly appreciated! :)
Jason
Here is my custom object code:
public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
//create a command and prepare it for execution
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
//create the DataAdapter & DataSet
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet(); // ** ds.Tables[0].TableName will be "MemberInfo" which is being pulled from DataSet.xsd) I need this DataSet to reference the custom info I am passing in, not the DataSet.xsd.
//fill the DataSet using default values for DataTable names, etc.
da.Fill(ds);
// detach the SqlParameters from the command object, so they can be used again.
cmd.Parameters.Clear();
//return the dataset
return ds;
}
Kevin Yu - M...
All-Star
19021 Points
1467 Posts
Re: DataSet.xsd problems with SQLHelper business object
Feb 22, 2007 01:45 AM|LINK
Hi Jason,
From the code, I can see that you're using a SqlHelper class to get the command execute and return a DataSet.
Based on my experience, the SqlHelper class provided in the Data Access Application Block is only suitable to be used for an untyped DataSet. If you have your own Business Logic Layer and need to use a typed DataSet you defined, I suggest you customize your own Data Access Layer.
You can create and fill a typed DataSet instance and return it to BLL.
Kevin Yu
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Mark as Not Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.