C
Caleb
My stored procedure returns three different result sets, but I can
only get the first returned result set into my strongly-typed dataset.
My strongly typed dataset was created through visual studio by
dragging and dropping the stored proc through the design tools. There
are three matching tables in my strongly typed dataset.
Even if I set the tablemappings, I can not get it to fill all three
tables when I call sqlDataAdapter.Fill(userDS). I can get it to fill
the first table if I call sqlDataAdapter.Fill(userDS,"User"), but then
if I try to call sqlDataAdapter.Fill(userDS,"Role") it fails with the
error message "Failed to enable constraints. One or more rows contains
values violating non-null, unique, or foriegn-key constraints.". If I
change the stored proc to return my "Role" record set first then I can
do a sqlDataAdapter.Fill(userDS,"Role") and it will work, but then
when I try to fill the "User" table it throws the same exception.
In summary I can only get the first result set into my strongly typed
dataset, and only if I use the
sqlDataAdapter.Fill(dataset,"tablename"). I can not get the
tablemappings to work at all. Please help!
string dbConnectionString =
System.Configuration.ConfigurationSettings.AppSettings[APPLICATION_SETTING_DBCONNECTIONSTRING];
this.sqlConnection = new SqlConnection(dbConnectionString);
this.sqlConnection.Open();
this.sqlDataAdapter = new
SqlDataAdapter(selectCommandText,this.sqlConnection);
this.sqlCommandBuilder = new SqlCommandBuilder(sqlDataAdapter);
string selectCommandText = "MRC_RetrieveUser";
this.ConnectDB(selectCommandText);
this.sqlDataAdapter.SelectCommand.CommandType =
System.Data.CommandType.StoredProcedure;
this.sqlDataAdapter.TableMappings.Add("User","User");
this.sqlDataAdapter.TableMappings.Add("Role","Role");
this.sqlDataAdapter.TableMappings.Add("Action","Action");
//no exception is thrown, but nothing makes it into the dataset:
this.sqlDataAdapter.Fill(userDS);
//or I can try:
this.sqlDataAdapter.Fill(userDS,"User");
//throws an exception here:
this.sqlDataAdapter.Fill(userDS,"Role");
this.sqlDataAdapter.Fill(userDS,"Action");
Any help is much appreciated.
only get the first returned result set into my strongly-typed dataset.
My strongly typed dataset was created through visual studio by
dragging and dropping the stored proc through the design tools. There
are three matching tables in my strongly typed dataset.
Even if I set the tablemappings, I can not get it to fill all three
tables when I call sqlDataAdapter.Fill(userDS). I can get it to fill
the first table if I call sqlDataAdapter.Fill(userDS,"User"), but then
if I try to call sqlDataAdapter.Fill(userDS,"Role") it fails with the
error message "Failed to enable constraints. One or more rows contains
values violating non-null, unique, or foriegn-key constraints.". If I
change the stored proc to return my "Role" record set first then I can
do a sqlDataAdapter.Fill(userDS,"Role") and it will work, but then
when I try to fill the "User" table it throws the same exception.
In summary I can only get the first result set into my strongly typed
dataset, and only if I use the
sqlDataAdapter.Fill(dataset,"tablename"). I can not get the
tablemappings to work at all. Please help!
string dbConnectionString =
System.Configuration.ConfigurationSettings.AppSettings[APPLICATION_SETTING_DBCONNECTIONSTRING];
this.sqlConnection = new SqlConnection(dbConnectionString);
this.sqlConnection.Open();
this.sqlDataAdapter = new
SqlDataAdapter(selectCommandText,this.sqlConnection);
this.sqlCommandBuilder = new SqlCommandBuilder(sqlDataAdapter);
string selectCommandText = "MRC_RetrieveUser";
this.ConnectDB(selectCommandText);
this.sqlDataAdapter.SelectCommand.CommandType =
System.Data.CommandType.StoredProcedure;
this.sqlDataAdapter.TableMappings.Add("User","User");
this.sqlDataAdapter.TableMappings.Add("Role","Role");
this.sqlDataAdapter.TableMappings.Add("Action","Action");
//no exception is thrown, but nothing makes it into the dataset:
this.sqlDataAdapter.Fill(userDS);
//or I can try:
this.sqlDataAdapter.Fill(userDS,"User");
//throws an exception here:
this.sqlDataAdapter.Fill(userDS,"Role");
this.sqlDataAdapter.Fill(userDS,"Action");
Any help is much appreciated.