C
citytroop
Hi,
I am creating a generic data access module for an application and I
have come across the following problem:
A form calls the function that loads data from a table to a grid. Then
the code below is called in order to effect any changes in the dataset.
The problem appears with a table that has 43 columns. When in the
selectCommand I pass a select statement containing up to 32 columns it
works without problems. When I increase the number of columns it gives
a "Concurrency violation: the UpdateCommand affected 0 records."
exception. Is this some because of some limitation or am I making an
error in the code?
The table contains 4555 records
public void SaveDataFromGrid(DataSet dsName, string dtName, string
selectCommand)
{
//DGM 20040109
//This code works only for single table updates.
//Create new Connection
OdbcConnection dbConnection = new OdbcConnection(strConnectionString);
//Set the sql command that will fill the dataset
OdbcCommand sqlCommand = new OdbcCommand(selectCommand, dbConnection);
sqlCommand.CommandTimeout = 30;
//Set the sql command that will update the dataset
//Set the data adapter
OdbcDataAdapter dbDataAdapter = new OdbcDataAdapter();
OdbcCommandBuilder cb = new OdbcCommandBuilder(dbDataAdapter);
dbDataAdapter.SelectCommand = sqlCommand;
//Open the connection
dbConnection.Open();
//Fill the dataset with the data
dbDataAdapter.Update(dsName, dtName);
//Close the database connection
dbConnection.Close();
//return true;
}
Thanks in advance for the help
I am creating a generic data access module for an application and I
have come across the following problem:
A form calls the function that loads data from a table to a grid. Then
the code below is called in order to effect any changes in the dataset.
The problem appears with a table that has 43 columns. When in the
selectCommand I pass a select statement containing up to 32 columns it
works without problems. When I increase the number of columns it gives
a "Concurrency violation: the UpdateCommand affected 0 records."
exception. Is this some because of some limitation or am I making an
error in the code?
The table contains 4555 records
public void SaveDataFromGrid(DataSet dsName, string dtName, string
selectCommand)
{
//DGM 20040109
//This code works only for single table updates.
//Create new Connection
OdbcConnection dbConnection = new OdbcConnection(strConnectionString);
//Set the sql command that will fill the dataset
OdbcCommand sqlCommand = new OdbcCommand(selectCommand, dbConnection);
sqlCommand.CommandTimeout = 30;
//Set the sql command that will update the dataset
//Set the data adapter
OdbcDataAdapter dbDataAdapter = new OdbcDataAdapter();
OdbcCommandBuilder cb = new OdbcCommandBuilder(dbDataAdapter);
dbDataAdapter.SelectCommand = sqlCommand;
//Open the connection
dbConnection.Open();
//Fill the dataset with the data
dbDataAdapter.Update(dsName, dtName);
//Close the database connection
dbConnection.Close();
//return true;
}
Thanks in advance for the help