日期:2014-05-16  浏览次数:21067 次

mysql数据库访问次数的限制问题?
各位老师:我在wxwidgets下对数据库进行写入操作,当我调用这个函数的时候,插入数据次数只能插入100次就弹出:不能建立连接 对话框,请问这个是什么原因?请老师指点,谢谢。
void DataBaseDialog::InsertDataBase( wxCommandEvent& event )
{
wxDbConnectInf *DbConnectInf = NULL; // 定义数据库连接信息指针DB connection information
wxDb *Conn = NULL; // 定义数据库连接指针Database connection
wxDbTable *table = NULL; // 定义数据表指针Data table to mysql

  DbConnectInf = new wxDbConnectInf(0, wxT(""), wxT(""), wxT(""));//这里定义的内容基本没用,但不定义会报错

Conn = new wxDb(DbConnectInf->GetHenv());

bool DBfailOnDataTypeUnsupported=!true;//

if(!Conn->Open(wxT("driver={mysql odbc 5.1 driver};server=192.168.100.13;DSN=icdata_db;charset=gb2312;database=icdata_db;uid=root;pwd=duangexin;port=3306;"),DBfailOnDataTypeUnsupported))//使用驱动程序的方式打开数据库
{
wxMessageBox("不能建立连接","DB CONNECTION ERROR", wxOK | wxICON_EXCLAMATION);
}

table = new wxDbTable(Conn, wxT("ictable"),10,wxT(""),!wxDB_QUERY_ONLY, wxT(""));

//定义保存列内容的变量
wxString sst;
wxChar ChipNumbers[100];
wxChar ChipCounts[100];
wxChar ChipTypes[100];
wxChar InspectorNumbers[100];
wxChar CheckTimes[100];
wxChar BugTypes[100];
wxChar CheckItems[100];
wxChar CheckResults[100];
wxChar ErrorCounts[100];
wxChar ErrorPercents[100];

//有几列就定义几列
table->SetColDefs(0, wxT("ChipNumber"), DB_DATA_TYPE_VARCHAR,ChipNumbers, SQL_C_WXCHAR, sizeof(ChipNumbers), true, true);
table->SetColDefs(1, wxT("ChipCount"), DB_DATA_TYPE_VARCHAR, ChipCounts,SQL_C_WXCHAR, sizeof(ChipCounts), true, true);
table->SetColDefs(2,wxT("ChipType"),DB_DATA_TYPE_VARCHAR,ChipTypes,SQL_C_WXCHAR,sizeof(ChipTypes),true,true);
table->SetColDefs(3, wxT("InspectorNumber"), DB_DATA_TYPE_VARCHAR,InspectorNumbers, SQL_C_WXCHAR, sizeof(InspectorNumbers), true, true);
table->SetColDefs(4, wxT("CheckTime"), DB_DATA_TYPE_VARCHAR, CheckTimes,SQL_C_WXCHAR, sizeof(CheckTimes), true, true);
table->SetColDefs(5,wxT("BugType"),DB_DATA_TYPE_VARCHAR,BugTypes,SQL_C_WXCHAR,sizeof(BugTypes),true,true);
table->SetColDefs(6, wxT("CheckItem"), DB_DATA_TYPE_VARCHAR,CheckItems, SQL_C_WXCHAR, sizeof(CheckItems), true, true);
table->SetColDefs(7, wxT("CheckResult"), DB_DATA_TYPE_VARCHAR, CheckResults,SQL_C_WXCHAR, sizeof(CheckResults), true, true);
table->SetColDefs(8,wxT("ErrorCount"),DB_DATA_TYPE_VARCHAR,ErrorCounts,SQL_C_WXCHAR,sizeof(ErrorCounts),true,true);
table->SetColDefs(9, wxT("ErrorPercent"), DB_DATA_TYPE_VARCHAR,ErrorPercents, SQL_C_WXCHAR, sizeof(ErrorPercents), true, true);

//打开DbTable对象
if( !table->Open())
{
wxMessageBox("不能打开数据库结构表!");
return;
}

//获取当天操作时间
wxDateTime now = wxDateTime::Now();
wxString strDate = now.Format(wxT("%Y-%m-%d"));

// //添加新记录
  wxStrcpy(ChipNumbers, wxT("2323")); //ChipNumbers所绑定的字段将添加一条记录
  wxStrcpy(ChipCounts,wxT("3"));
  wxStrcpy(ChipTypes,wxT("3"));
  wxStrcpy(InspectorNumbers,wxT("13"));
  wxStrcpy(CheckTimes,wxT("2009-12-29"));
  wxStrcpy(BugTypes,wxT("3"));
  wxStrcpy(CheckItems,wxT("3"));
wxStrcpy(CheckResults,wxT("false"));
wxStrcpy(ErrorCounts,wxT("3"));
  wxStrcpy(ErrorPercents,wxT("3"));

 
if(!table->Insert())

{

//判断添加是否成功
wxMessageBox("添加失败!");
return;

}

//提交更新数据库

table->GetDb()->CommitTrans();