主题:運算式太複雜
大家好, 我是C# .NET 的新手,
刚接手了一个旧的系统, 是用 Visual Studio. NET 2002 (C#) 编写的, 数据库是使用 Ms Access 2000,
我需要在一个现有版面加入多个新的 Input Text Box 让用家输入资料,
我首先试加一个 Input Textbox (亦同时在 Access database 增加相应的字段).
成功可以更新及储存.
再加第2个时, 亦成功.
但当我再用相同方式加入第3个新的 Input TextBox 时,
每当我选择 修改或储存时, 就会再现 error.
"Microsoft JET Database Engine: 表达式太复杂"
好象我不能再加多新的字段去更新及储存.
Access 有否限制同一次储存多少个字段 ?
请问大家有无遇过类似问题 ?
请问有什么方法解决 ? 先谢谢大家.
以下是节录了 更新及储存的程序代码:
============================
private bool SaveRecordToSrv()
{
bool blnSuccess = false;
string strSaveStatus="";
try
{
UpdateAppTempInfo();
EndDataSetCurrentEdit();
if (CheckValidate())
{
if (strStatusMode == "NEW" || strStatusMode == "EDIT")
{
string dbConnectionString = Startup.dbConnectionString;
AppFacade.SaveApp(dbConnectionString, dsAppData);
dsAppData.AcceptChanges();
if (strStatusMode == "NEW")
{
if (RetrieveAppID())
{
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_ID] = txtAppID.Text;
strSEQNO = txtSeqNo.Text;
dsAppData.AcceptChanges();
strStatusMode = "EDIT";
}
strSaveStatus = "saved";
}
else
{
strSaveStatus = "updated";
}
ABORTRecord();
MessageBox.Show(this, "Record has been " + strSaveStatus + "!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
strAPPID = dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_ID].ToString();
}
}
}
catch (Exception ex)
{
MessageBox.Show(this, "Record cannot be saved!\n" + ex.Source + ": " + ex.Message, this.Text + "-SaveRecordToSrv", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Cursor.Current = Cursors.Default;
return blnSuccess;
}
......
......
private void UpdateAppTempInfo()
{
switch (strStatusMode)
{
case "NEW":
string dbConnectionString = Startup.dbConnectionString;
bool blnIsSARS = chkSARS.Checked;
string strBatchNo = SysParamFacade.GetLatestBatchNo(dbConnectionString);
string strAppNo = SysParamFacade.GetNextAppNo(dbConnectionString, blnIsSARS);
if (blnIsSARS)
{
dsAppData.Tables[SysParamData.SYS_TABLE_NAME].Rows[0][SysParamData.SYS_PARAM_SARS_APP_NO] = strAppNo;
strAppNo = System.Configuration.ConfigurationSettings.AppSettings["SARSAppNoPrefix"].ToString() + strAppNo;
}
else
{
dsAppData.Tables[SysParamData.SYS_TABLE_NAME].Rows[0][SysParamData.SYS_PARAM_APP_NO] = strAppNo;
}
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_BATCH_NO] = strBatchNo;
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_NO] = strAppNo;
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_CREATE_DATE] = System.DateTime.Now;
break;
case "EDIT":
string strNew = dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_RESPONSE_USER].ToString();
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_MODIFY_DATE] = System.DateTime.Now;
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_MODIFY_BY] = Startup.UserID;
break;
}
}
............
............
private void NEWRecord()
{
InitAppInfo();
ShowApp();
RefreshForm();
strStatusMode = "NEW";
ShowStatus();
ChangePermit(true);
txtResubmitDate.Enabled = false;
txtAppName.Focus();
}
private void EDITRecord()
{
if (SelectedRecord())
{
if ((dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.CANCELLED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.EXPIRED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.REJECTED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.COMPLETED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.WITHDRAWN)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.LAPSED)))
{
MessageBox.Show(this, "Cannot modify Application!\nApplication is " + dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS_DESC] + ".",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
//added on 241103, avoid Concurrency Update from other Application related forms
ShowData(strAPPID, strSEQNO);
strStatusMode = "EDIT";
ShowStatus();
ChangePermit(true);
txtAppID.Visible = false;
txtBatchNo.Visible = false;
lblAppNo.Visible = true;
lblBatchNo.Visible = true;
this.dsAppData.AcceptChanges();
txtAppName.Focus();
}
}
}
private void SAVERecord()
{
//Save function
panelCode.Focus();
Cursor.Current = Cursors.WaitCursor;
if (SaveRecordToSrv())
{
ChangePermit(false);
GridRefresh();
txtAppID.Visible = true;
txtBatchNo.Visible = true;
lblAppNo.Visible = false;
lblBatchNo.Visible = false;
grdOrg.Enabled = true;
}
Cursor.Current = Cursors.Default;
}
.....
.....
你好, 程式碼的全部 (Full version) 放於
http://www.efilehk.org/job/frmAppMain2.cs
http://www.efilehk.org/job/AppData.cs
刚接手了一个旧的系统, 是用 Visual Studio. NET 2002 (C#) 编写的, 数据库是使用 Ms Access 2000,
我需要在一个现有版面加入多个新的 Input Text Box 让用家输入资料,
我首先试加一个 Input Textbox (亦同时在 Access database 增加相应的字段).
成功可以更新及储存.
再加第2个时, 亦成功.
但当我再用相同方式加入第3个新的 Input TextBox 时,
每当我选择 修改或储存时, 就会再现 error.
"Microsoft JET Database Engine: 表达式太复杂"
好象我不能再加多新的字段去更新及储存.
Access 有否限制同一次储存多少个字段 ?
请问大家有无遇过类似问题 ?
请问有什么方法解决 ? 先谢谢大家.
以下是节录了 更新及储存的程序代码:
============================
private bool SaveRecordToSrv()
{
bool blnSuccess = false;
string strSaveStatus="";
try
{
UpdateAppTempInfo();
EndDataSetCurrentEdit();
if (CheckValidate())
{
if (strStatusMode == "NEW" || strStatusMode == "EDIT")
{
string dbConnectionString = Startup.dbConnectionString;
AppFacade.SaveApp(dbConnectionString, dsAppData);
dsAppData.AcceptChanges();
if (strStatusMode == "NEW")
{
if (RetrieveAppID())
{
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_ID] = txtAppID.Text;
strSEQNO = txtSeqNo.Text;
dsAppData.AcceptChanges();
strStatusMode = "EDIT";
}
strSaveStatus = "saved";
}
else
{
strSaveStatus = "updated";
}
ABORTRecord();
MessageBox.Show(this, "Record has been " + strSaveStatus + "!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
strAPPID = dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_ID].ToString();
}
}
}
catch (Exception ex)
{
MessageBox.Show(this, "Record cannot be saved!\n" + ex.Source + ": " + ex.Message, this.Text + "-SaveRecordToSrv", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Cursor.Current = Cursors.Default;
return blnSuccess;
}
......
......
private void UpdateAppTempInfo()
{
switch (strStatusMode)
{
case "NEW":
string dbConnectionString = Startup.dbConnectionString;
bool blnIsSARS = chkSARS.Checked;
string strBatchNo = SysParamFacade.GetLatestBatchNo(dbConnectionString);
string strAppNo = SysParamFacade.GetNextAppNo(dbConnectionString, blnIsSARS);
if (blnIsSARS)
{
dsAppData.Tables[SysParamData.SYS_TABLE_NAME].Rows[0][SysParamData.SYS_PARAM_SARS_APP_NO] = strAppNo;
strAppNo = System.Configuration.ConfigurationSettings.AppSettings["SARSAppNoPrefix"].ToString() + strAppNo;
}
else
{
dsAppData.Tables[SysParamData.SYS_TABLE_NAME].Rows[0][SysParamData.SYS_PARAM_APP_NO] = strAppNo;
}
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_BATCH_NO] = strBatchNo;
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_APP_NO] = strAppNo;
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_CREATE_DATE] = System.DateTime.Now;
break;
case "EDIT":
string strNew = dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_RESPONSE_USER].ToString();
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_MODIFY_DATE] = System.DateTime.Now;
dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_MODIFY_BY] = Startup.UserID;
break;
}
}
............
............
private void NEWRecord()
{
InitAppInfo();
ShowApp();
RefreshForm();
strStatusMode = "NEW";
ShowStatus();
ChangePermit(true);
txtResubmitDate.Enabled = false;
txtAppName.Focus();
}
private void EDITRecord()
{
if (SelectedRecord())
{
if ((dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.CANCELLED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.EXPIRED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.REJECTED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.COMPLETED)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.WITHDRAWN)) ||
(dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS].ToString()==Convert.ToString(AppData.AppStatus.LAPSED)))
{
MessageBox.Show(this, "Cannot modify Application!\nApplication is " + dsAppData.Tables[strAPPTABLE].Rows[0][AppData.SYS_STATUS_DESC] + ".",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
//added on 241103, avoid Concurrency Update from other Application related forms
ShowData(strAPPID, strSEQNO);
strStatusMode = "EDIT";
ShowStatus();
ChangePermit(true);
txtAppID.Visible = false;
txtBatchNo.Visible = false;
lblAppNo.Visible = true;
lblBatchNo.Visible = true;
this.dsAppData.AcceptChanges();
txtAppName.Focus();
}
}
}
private void SAVERecord()
{
//Save function
panelCode.Focus();
Cursor.Current = Cursors.WaitCursor;
if (SaveRecordToSrv())
{
ChangePermit(false);
GridRefresh();
txtAppID.Visible = true;
txtBatchNo.Visible = true;
lblAppNo.Visible = false;
lblBatchNo.Visible = false;
grdOrg.Enabled = true;
}
Cursor.Current = Cursors.Default;
}
.....
.....
你好, 程式碼的全部 (Full version) 放於
http://www.efilehk.org/job/frmAppMain2.cs
http://www.efilehk.org/job/AppData.cs