Expression too complex

J

Joe

Hi all,

I am a newbie of .NET c# programming.
I just take over a Data Recording System which use Visual Studio. NET 2002
(C#) to built a PC-based application, and use Ms Access 2000 as database.

I need to enhance a existing Windows Form that add more fields for user to
input.

First of all, I add one textbox for testing, it works fine to save and
retrieve.
and then I add the second textbox.... it's OK.

But when I add the third one. Error occurs.
When I click the SAVE button. It prompt a error message that "Expression too
complex". So that I cannot save and add more input field to this Windows Form.

Do you have any idea and solution of this error.
I really need your help. Thanks.

The application is using OleDbCommandBuilder, DataAdapter.Update() for
update, insert, etc.
 
M

Marc Gravell

For a start, it would help if you could post the full exception
details, such as the name of the exception (in addition to the
message), and possibly anything else of interest (inner exceptions?
etc). It *sounds* like this is being thrown by access, in which case
you're going to have trouble... perhaps consider a two-phase save?
i.e. save the first set of values, then the second set?

Marc
 
J

Joe

Hi marc, thx for your reply.

Hi all, thx for your reply.

The system use DataAdapter.Update() to update dataset

When user click <b>SAVE</b> button, it would run the following function.

AppFacade.<b>SaveApp</b>(dbConnectionString, dsAppData);


And <b>SaveApp</b> function as follows:


public void <b>SaveApp</b>(String dbConnectionString, DataSet dsData)
{

DBExecute dbexe = new DBEngine.DBExecute();
DataTable dtApp = dsData.Tables[AppData.SYS_TABLE_NAME];
DataTable dtLoc = dsData.Tables[AppDetailData.SYS_PROJ_LOCATION_TABLE];
......
......
try
{
dbexe.dbConnectionString = dbConnectionString;
dbexe.TransactionInitial();
<b>dbexe.UpdateDataTable(dtApp)</b>;
dbexe.UpdateDataTable(dtExtApp);
......
......
dbexe.TransactionComplete();
}
catch (Exception e)
{
dbexe.TransactionRollBack();
throw e;
}
finally
{
dbexe = null;
dtApp = null;
dtExtApp = null;
......
......
}
}




// Public functions to update a datatable



public int <b>UpdateDataTable</b>(DataTable dt)
{
this.BuildCommands(dt.TableName);

if (dt.GetChanges() != null)
{
int intRtn = pAdapter.Update(dt.GetChanges());
return intRtn;
}
else
return 0;
}



public int UpdateDataTable(DataSet ds, string tableName)
{
this.BuildCommands(tableName);

if (ds.Tables[tableName].GetChanges() != null)
return pAdapter.Update(ds.GetChanges(), tableName);
else
return 0;
}



.....

.....



/// Public functions to build SQL command and parameters
private void BuildCommands(string tableName)
{
string strCommand = "SELECT * FROM " + tableName;

OleDbCommand comm = new OleDbCommand(strCommand, pConnection);
comm.CommandType = CommandType.Text;
comm.Transaction = myTrans;

pAdapter.SelectCommand = comm;

OleDbCommandBuilder cb = new OleDbCommandBuilder(pAdapter);
pAdapter.InsertCommand = cb.GetInsertCommand();
pAdapter.UpdateCommand = cb.GetUpdateCommand();
pAdapter.DeleteCommand = cb.GetDeleteCommand();

pAdapter.SelectCommand.Transaction = myTrans;
pAdapter.InsertCommand.Transaction = myTrans;
pAdapter.UpdateCommand.Transaction = myTrans;
pAdapter.DeleteCommand.Transaction = myTrans;
}
 
J

Joe

Sorry that there is typing mistake in previous post, pls ignore.

Hi marc, thx for your reply.

The system use DataAdapter.Update() to update dataset

When user click SAVE button, it would run the following function.

AppFacade.SaveApp(dbConnectionString, dsAppData);


And SaveApp function as follows:


public void SaveApp(String dbConnectionString, DataSet dsData)
{

DBExecute dbexe = new DBEngine.DBExecute();
DataTable dtApp = dsData.Tables[AppData.SYS_TABLE_NAME];
DataTable dtLoc = dsData.Tables[AppDetailData.SYS_PROJ_LOCATION_TABLE];
......
......
try
{
dbexe.dbConnectionString = dbConnectionString;
dbexe.TransactionInitial();
dbexe.UpdateDataTable(dtApp);
dbexe.UpdateDataTable(dtExtApp);
......
......
dbexe.TransactionComplete();
}
catch (Exception e)
{
dbexe.TransactionRollBack();
throw e;
}
finally
{
dbexe = null;
dtApp = null;
dtExtApp = null;
......
......
}
}




// Public functions to update a datatable



public int UpdateDataTable(DataTable dt)
{
this.BuildCommands(dt.TableName);

if (dt.GetChanges() != null)
{
int intRtn = pAdapter.Update(dt.GetChanges());
return intRtn;
}
else
return 0;
}



public int UpdateDataTable(DataSet ds, string tableName)
{
this.BuildCommands(tableName);

if (ds.Tables[tableName].GetChanges() != null)
return pAdapter.Update(ds.GetChanges(), tableName);
else
return 0;
}



.....

.....



/// Public functions to build SQL command and parameters
private void BuildCommands(string tableName)
{
string strCommand = "SELECT * FROM " + tableName;

OleDbCommand comm = new OleDbCommand(strCommand, pConnection);
comm.CommandType = CommandType.Text;
comm.Transaction = myTrans;

pAdapter.SelectCommand = comm;

OleDbCommandBuilder cb = new OleDbCommandBuilder(pAdapter);
pAdapter.InsertCommand = cb.GetInsertCommand();
pAdapter.UpdateCommand = cb.GetUpdateCommand();
pAdapter.DeleteCommand = cb.GetDeleteCommand();

pAdapter.SelectCommand.Transaction = myTrans;
pAdapter.InsertCommand.Transaction = myTrans;
pAdapter.UpdateCommand.Transaction = myTrans;
pAdapter.DeleteCommand.Transaction = myTrans;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top