本文整理汇总了C++中RunSQL函数的典型用法代码示例。如果您正苦于以下问题:C++ RunSQL函数的具体用法?C++ RunSQL怎么用?C++ RunSQL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RunSQL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunSQL
//---------------------------------------------------------------------------
void __fastcall TUnitTreatListForm::FormShow(TObject *Sender)
{
CString szSQL;
szSQL="select * from diccorp order by cp_code";
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
m_lstCorpID.Add(dm1->Query1->FieldByName("cp_code")->AsString.c_str());
lstCorp->Items->Add(dm1->Query1->FieldByName("cp_name")->AsString);
dm1->Query1->Next();
}
lstCorp->ItemIndex=0;
m_lstLargeID.Add("");
lstLarge->Items->Add("全部");
szSQL="select * from diclargetype order by lt_code";
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
m_lstLargeID.Add(dm1->Query1->FieldByName("lt_code")->AsString.c_str());
lstLarge->Items->Add(dm1->Query1->FieldByName("lt_name")->AsString);
dm1->Query1->Next();
}
lstLarge->ItemIndex=0;
}
示例2: RunSQL
//---------------------------------------------------------------------------
void __fastcall TAskPurchaseListForm::FormShow(TObject *Sender)
{
int nYear,nMonth,nDay;
char strDate0[80],strDate1[80];
CString szSQL;
edtID ->Text="";
edtReqDate0 ->Text="";
edtNeedDate ->Text="";
edtMncode ->Text="";
m_lstStockDepID.Add("");
lstStockDep->Items->Add("全部");
szSQL="select * from StockDepart order by sd_code";
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
m_lstStockDepID.Add(dm1->Query1->FieldByName("sd_code")->AsString.c_str());
lstStockDep->Items->Add(dm1->Query1->FieldByName("sd_name")->AsString);
dm1->Query1->Next();
}
lstType ->ItemIndex=0;
lstReqType ->ItemIndex=0;
// lstBuyType ->ItemIndex=0;
lstNeedType ->ItemIndex=0;
lstStockDep ->ItemIndex=0;
lstStockType->ItemIndex=0;
lstReqCorp->Items->Add("全部");
m_lstCorpID.Add("");
szSQL="select * from DepartCorp order by dc_code";
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
m_lstCorpID.Add(dm1->Query1->FieldByName("dc_code")->AsString.c_str());
lstReqCorp->Items->Add(dm1->Query1->FieldByName("dc_name")->AsString);
dm1->Query1->Next();
}
lstReqCorp->ItemIndex=0;
ResetReqDepart();
lstAfm->ItemIndex=0;
lstEndFlag->ItemIndex=0;
lstStockman->Items->Add("全部");
m_lstStockmanID.Add("");
szSQL="select * from StockHandleman order by sh_code";
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
m_lstStockmanID.Add(dm1->Query1->FieldByName("sh_code")->AsString.c_str());
lstStockman->Items->Add(dm1->Query1->FieldByName("sh_name")->AsString);
dm1->Query1->Next();
}
lstStockman->ItemIndex=0;
FormResize(Sender);
ResetCtrl();
}
示例3: Cleanup
bool Cleanup(OWConnection* connection, std::string tableName)
{
std::ostringstream oss;
OWStatement* statement = 0;
oss << "DELETE FROM " << tableName;
statement = RunSQL(connection, oss);
if (statement != 0) delete statement;
oss.str("");
oss << "DROP TABLE " << tableName;
std::cout << oss.str() << std::endl;
statement = RunSQL(connection, oss);
if (statement != 0) delete statement;
oss.str("");
oss << "DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='"<< tableName << "'";
statement = RunSQL(connection, oss);
if (statement != 0) delete statement;
oss.str("");
connection->Commit();
return true;
}
示例4: CreateBlockIndex
bool CreateBlockIndex( OWConnection* connection,
std::string tableName,
long srid,
bool bUse3d)
{
boost::ignore_unused_variable_warning(srid);
std::ostringstream oss;
OWStatement* statement = 0;
oss << "CREATE INDEX "<< tableName <<"_cloud_idx on "<<tableName<<"(blk_extent) INDEXTYPE IS MDSYS.SPATIAL_INDEX";
if (bUse3d) {
oss <<" PARAMETERS('sdo_indx_dims=3')" ;
}
statement = RunSQL(connection, oss);
if (statement != 0) delete statement; else return false;
oss.str("");
oss << "CREATE INDEX "<< tableName <<"_objectid_idx on "<<tableName<<"(OBJ_ID,BLK_ID) COMPRESS 2" ;
statement = RunSQL(connection, oss);
if (statement != 0) delete statement; else return false;
oss.str("");
return true;
}
示例5: RunSQL
void TTreatStockAfmForm::RefreshData()
{
TListItem *pItem;
CString szSQL;
char strDepart[80],strTemp[80],strCorp[80];
// szSQL.Format("select * from StockHandleman where sh_code='%s'",operatorcode.c_str());
// RunSQL(dm1->Query1,szSQL,true);
// if(dm1->Query1->Eof) strDepart[0]='\0';
// else strcpy(strDepart,dm1->Query1->FieldByName("sh_sdcode")->AsString.c_str());
lstView->Items->Clear();
if(operatorcode!="admin")
{
szSQL.Format("select * from operator where op_code='%s'",operatorcode.c_str());
RunSQL(dm1->Query1,szSQL,true);
if(dm1->Query1->Eof) return;
strcpy(strCorp,dm1->Query1->FieldByName("op_cpcode")->AsString.c_str());
szSQL.Format("select * from TreatStock,operator,materialno where (ts_afmdate is null or ts_afmdate2 is null)"
" and op_code=ts_shcode and op_cpcode='%s' and ts_mncode*=mn_code",strCorp);
}
else
szSQL="select * from TreatStock,materialno"
" where ts_mncode*=mn_code and (ts_afmdate is null or ts_afmdate2 is null)";
szSQL+=" order by ts_inputdate,ts_code";
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
// if(strDepart[0]!='\0')
// {
// strcpy(strTemp,dm1->Query1->FieldByName("ap_code")->AsString.c_str());
// if(dm1->Query1->FieldByName("ap_sdcode")->AsString!=strDepart)
// {
// dm1->Query1->Next();
// continue;
// }
// }
pItem=lstView->Items->Add();
assert(pItem!=NULL);
pItem->Caption=dm1->Query1->FieldByName("ts_code")->AsString;
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_inputdate")));
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_modifydate")));
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_afmdate")));
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_afmdate2")));
pItem->SubItems->Add(FloatField2String(dm1->Query1->FieldByName("ts_price"),2));
pItem->SubItems->Add(dm1->Query1->FieldByName("mn_name")->AsString);
dm1->Query1->Next();
}
edtID->Text="";
ResetCtrl();
}
示例6: varchar
void __fastcall TBookNotAcceptListForm::btnprintClick(TObject *Sender)
{
CString szSQL,szTable;
int i;
TListItem *pItem;
TPrnBookNotAcceptForm *pPrn;
TDateTime tNow;
szTable=GetTmpTableName();
szSQL.Format("create table dbo.%s ("
"m_bookid varchar(20),"
"m_date varchar(20),"
"m_days varchar(4),"
"m_mncode varchar(25),"
"m_mnname varchar(80),"
"m_corp varchar(20),"
"m_sdname varchar(20)"
")",szTable);
if(!RunSQL(dm1->Query1,szSQL)) return;
//if(lstView->Items->Count>0)
//lstView->SelectAll();
for(i=0;i<lstView->Items->Count;i++)
{
pItem=lstView->Items->Item[i];
szSQL.Format("insert into %s values(",szTable);
szSQL+=Str2DBString(pItem->Caption.c_str());
szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[0].c_str());
szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[1].c_str());
szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[2].c_str());
szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[3].c_str());
szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[4].c_str());
szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[6].c_str());
szSQL+=")";
if(!RunSQL(dm1->Query1,szSQL)) goto DROP_TABLE;
}
pPrn=new TPrnBookNotAcceptForm(this);
assert(pPrn!=NULL);
tNow=GetSysTime(false);
pPrn->txtPrnTime->Caption=(LPCSTR)Time2DBTimeString(tNow);
szSQL.Format("select * from %s order by m_bookid",szTable);
if(RunSQL(dm1->sqlPrint,szSQL,true))
{pPrn->PrnView->PreviewModal();}
delete pPrn;
DROP_TABLE:
szSQL.Format("drop table dbo.%s",szTable);
RunSQL(dm1->Query1,szSQL);
}
示例7: ResetCtrl
void __fastcall TTreatStockAfmForm::edtIDKeyDown(TObject *Sender,
WORD &Key, TShiftState Shift)
{
if(Key==VK_RETURN)
{
TListItem *pItem;
int i;
CString szSQL;
char strDepart[80];
if(edtID->Text.IsEmpty()) return;
for(i=0;i<lstView->Items->Count;i++)
{
pItem=lstView->Items->Item[i];
if(pItem->Caption==edtID->Text)
{
lstView->Selected=pItem;
ResetCtrl();
return;
}
}
szSQL.Format("select * from TreatStock where ts_code='%s'",edtID->Text.c_str());
RunSQL(dm1->Query1,szSQL,true);
if(dm1->Query1->Eof) return;
pItem=lstView->Items->Insert(0);
assert(pItem!=NULL);
pItem->Caption=dm1->Query1->FieldByName("ts_code")->AsString;
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_inputdate")));
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_modifydate")));
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_afmdate")));
pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("ts_afmdate2")));
lstView->Selected=pItem;
ResetCtrl();
}
}
示例8: sprintf
//---------------------------------------------------------------------------
void __fastcall TDicCurrencyForm::btnDeleteClick(TObject *Sender)
{
char strMsg[256],strSQL[512];
sprintf(strMsg,"\n 真要删除编号为“%s”的记录吗? \n",edtID->Text.c_str());
if(Application->MessageBox(strMsg,"警告",MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON2)!=IDYES)
return;
sprintf(strSQL,"delete from DicCurrency where crid='%s'",edtID->Text.c_str());
if(!dm1->OpenDatabase()) return;
if(!RunSQL(strSQL)) return;
TListItem *pItem;
pItem=ListView1->Selected;
if(pItem!=NULL)
{
int nSel=ListView1->Items->IndexOf(pItem);
ListView1->Items->Delete(nSel);
ListView1->Selected=NULL;
}
// if(nSel>=ctlListBox->Items->Count)
// nSel=ctlListBox->Items->Count-1;
// ctlListBox->ItemIndex=nSel;
// Row2Editor();
m_enWorkState=EN_IDLE;
ResetCtrl();
}
示例9: TPrnUnitTreatListForm
//---------------------------------------------------------------------------
void __fastcall TUnitTreatListForm::btnPrintClick(TObject *Sender)
{
CString szSQL,szFilter0,szFilter1;
char strCorp[80],strLarge[80],strTemp[80];
int nSel;
TListItem *pItem;
AnsiString szDays;
BASE2COLDATA rwBase;
TPrnUnitTreatListForm *pForm;
TDateTime tNow;
pForm=new TPrnUnitTreatListForm(Application);
assert(pForm!=NULL);
strCorp[0]='\0';
strLarge[0]='\0';
if((nSel=lstCorp->ItemIndex)>=0 && nSel<m_lstCorpID.GetSize())
{
strcpy(strCorp,m_lstCorpID[nSel]);
}
if((nSel=lstLarge->ItemIndex)>=0 && nSel<m_lstLargeID.GetSize())
{
strcpy(strLarge,m_lstLargeID[nSel]);
}
if(strCorp[0]!='\0' || strLarge[0]!='\0')
{
szFilter0.Format(" and mn_code like '%s%s%%'",strCorp,strLarge);
szFilter1.Format(" and pd_mncode like '%s%s%%'",strCorp,strLarge);
}
szSQL="select pd_mncode,count(pd_mncode) as pd_count from BookFactory,PurchaseDetail"
" where bf_apcode=pd_code";
szSQL+=szFilter1;
szSQL+=" group by pd_mncode"
" order by pd_mncode";
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
strcpy(rwBase.strCode,dm1->Query1->FieldByName("pd_mncode")->AsString.c_str());
sprintf(rwBase.strName,"%d",dm1->Query1->FieldByName("pd_count")->AsInteger);
pForm->m_lstBook.Add(rwBase);
dm1->Query1->Next();
}
szSQL="select * from TreatStock,DicUnits,materialno,Manufactur"
" where ts_ducode=du_code"
" and ts_mncode=mn_code"
" and ts_mfcode*=mf_code";
szSQL+=szFilter0;
szSQL+=" order by ts_mncode";
tNow=GetSysTime(false);
if(!OpenQuery(dm1->sqlPrint,szSQL)) return;
pForm->txtPrnDate->Caption=(LPCSTR)Time2DBDateString(tNow);
pForm->PrnView->PreviewModal();
delete pForm;
}
示例10: CPLError
OGRErr OGRGFTDataSource::DeleteLayer(int iLayer)
{
if (!bReadWrite)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in read-only mode");
return OGRERR_FAILURE;
}
if (osAccessToken.size() == 0)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in unauthenticated mode");
return OGRERR_FAILURE;
}
if( iLayer < 0 || iLayer >= nLayers )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Layer %d not in legal range of 0 to %d.",
iLayer, nLayers-1 );
return OGRERR_FAILURE;
}
CPLString osTableId = ((OGRGFTTableLayer*)papoLayers[iLayer])->GetTableId();
CPLString osLayerName = GetLayer(iLayer)->GetName();
/* -------------------------------------------------------------------- */
/* Blow away our OGR structures related to the layer. This is */
/* pretty dangerous if anything has a reference to this layer! */
/* -------------------------------------------------------------------- */
CPLDebug( "GFT", "DeleteLayer(%s)", osLayerName.c_str() );
delete papoLayers[iLayer];
memmove( papoLayers + iLayer, papoLayers + iLayer + 1,
sizeof(void *) * (nLayers - iLayer - 1) );
nLayers--;
/* -------------------------------------------------------------------- */
/* Remove from the database. */
/* -------------------------------------------------------------------- */
CPLString osSQL("DROP TABLE ");
osSQL += osTableId;
CPLHTTPResult* psResult = RunSQL( osSQL );
if (psResult == NULL || psResult->nStatus != 0)
{
CPLError(CE_Failure, CPLE_AppDefined, "Table deletion failed (1)");
CPLHTTPDestroyResult(psResult);
return OGRERR_FAILURE;
}
CPLHTTPDestroyResult(psResult);
return OGRERR_NONE;
}
示例11: ShowMessage
void __fastcall TApFilePageForm::btnMoveClick(TObject *Sender)
{
int nSel;
CString szSQL;
char strTemp[2048];
if(m_szActiveID.IsEmpty()) return;
if(m_szActiveID!=edtAPC->Text.c_str())
{
ShowMessage("您输入的单编号与正在查询的不同");
if(edtAPC->CanFocus()) edtAPC->SetFocus();
return;
}
if(Application->MessageBox("真要删除该项数据吗","警告",MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON2)!=IDYES) return;
szSQL.Format("select * from FilePage where fp_apcode='%s'",m_szActiveID);
RunSQL(dm1->Query1,szSQL,true);
if(dm1->Query1->Eof)
{
ShowMessage("该项数据不存在,可能已被其它人删除了");
return;
}
try
{
szSQL.Format("delete FilePage where fp_apcode=%s",Str2DBString(m_szActiveID));
RunSQL(dm1->Query1,szSQL);
}
catch(...)
{
sprintf(strTemp,"数据库操作失败,SQL=\n%s",szSQL);
ShowMessage(strTemp);
return;
}
m_szActiveID="";
edtAPC->Text="";
edtFC->Text="";
edtPC->Text="";
lstRem->ItemIndex=-1;
ResetCtrl();
return;
}
示例12: GetSysDate
//---------------------------------------------------------------------------
//新增时自动产生递增的档号
AnsiString TApFilePageForm::GenerateID()
{ //编号格式:GR-S-XXXXXX
int nYear,nMonth,nDay,nFlow;
char strID[80],chMon,strSQL[1024],strKey[80];
if(!dm1->OpenDatabase()) return "";
GetSysDate(nYear,nMonth,nDay,false);
if(nMonth<10) chMon=(char)('0'+nMonth);
else chMon=(char)('A'-10+nMonth);
//查看该月是否已经有流水号
sprintf(strKey,"FilePage_%04d%02d",nYear,nMonth);
sprintf(strSQL,"select * from RuntimeData where rd_key='%s'",strKey);
RunSQL(strSQL,true);
if(dm1->Query1->Eof)
{ //该月还没有流水号,初始化该月流水号
sprintf(strSQL,"insert into RuntimeData values('%s',1,NULL,'档案页码%d年%d月流水号')",
strKey,nYear,nMonth);
RunSQL(strSQL);
nFlow=1;
}
else
{
nFlow=dm1->Query1->FieldByName("rd_int")->AsInteger;
}
while(1)
{
sprintf(strID,"A%02d%02d%03d",nYear%10,nMonth,nFlow); //自动生成的档号默认以A开头
sprintf(strSQL,"select * from FilePage where fp_fno='%s'",strID);
RunSQL(strSQL,true);
if(dm1->Query1->Eof) break;
nFlow++;
}
sprintf(strSQL,"update RuntimeData set rd_int=%d where rd_key='%s'",nFlow,strKey);
RunSQL(strSQL);
return AnsiString(strID);
}
示例13: GrantPrivileges
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::GrantPrivileges(const AString& database, const AString& username)
{
bool success = false;
if ((success = RunSQL(AString::Formatify("grant all privileges on database %s to %s", database.str(), username.str()))) == false) {
debug("Failed to grant privileges on database: %s\n", GetErrorMessage().str());
}
return success;
}
示例14: RunSQL
//---------------------------------------------------------------------------
void __fastcall TXkQryForm::FormShow(TObject *Sender)
{
cbbQryOpCodeSl->Items->Add("");
CString szSQL = "";
szSQL.Format("select op_code from operator where op_class='%d'", E_OPERATOR_TYPE_SALER);
RunSQL(dm1->Query1,szSQL,true);
while(!dm1->Query1->Eof)
{
AnsiString opcode = dm1->Query1->FieldByName("op_code")->AsString;
cbbQryOpCodeSl->Items->Add(opcode);
dm1->Query1->Next();
}
}
示例15: AddUser
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::AddUser(const AString& username, const AString& password)
{
bool success = false;
if ((success = RunSQL(AString::Formatify("create user %s with password '%s'", username.str(), password.str()))) == false) {
AString errmsg = GetErrorMessage();
if (errmsg.PosNoCase("already exists") < 0) {
debug("Failed to create user '%s': %s\n", username.str(), errmsg.str());
}
else success = true;
}
return success;
}