请问VC控制台程序如何读取INI文件和操作SQL Server数据库,有没有相关的例程。
解决方案 »
- 请问如何绘制管道
- 关于未知领域的迷茫
- 大侠门吝啬个思路
- ReadProcessMemory问题
- 救命啊,用ADO访问ACCESS,调试成功,换到另外一台电脑就不行了
- 谁有关于打印机底层控制的电子书或资料,主要是关于本地打印机,共享打印机,网络打印机的不同控制方法
- 我一个工程想法
- 编一个把整数转换成mmm,mmm,mmm格式字符的函数,例如:f(12345)->123,45.不能用inttostr()等函数,可以用operator函数,谢谢!
- ASL是什么?
- InprocServer32的子键
- 如何控制WebBrowser,并使其提交其中的网页或者操纵其中的文本框等?
- 请问关于vs2003和vc6开发环境之间的转换问题
GetPrivateProfileInt
GetPrivateProfileSection
GetPrivateProfileSectionNames
GetPrivateProfileString
GetPrivateProfileStruct
GetProfileInt
GetProfileSection
GetProfileString
WritePrivateProfileSection
WritePrivateProfileString
WritePrivateProfileStruct
WriteProfileSection
WriteProfileString
#include <sqldb.h>
dbsqlexec (SQLString)
//#include <afxdisp.h>#import "c:\program files\common files\system\ado\msado15.dll" rename ("EOF","adoEOF") no_namespace#define CREATEiNSTANCE(sp,riid) { HRESULT _hr =sp .CreateInstance( __uuidof( riid ) ); \
if (FAILED(_hr)) _com_issue_error(_hr); }#define RsITEM(rs,x) rs->Fields->Item[_variant_t(x)]->Value
#define UC (char *)
struct InitOle {
InitOle() { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize(); }
} _init_InitOle_; // Global Instance to force load/unload of OLEvoid main(){ _RecordsetPtr spRS;
_RecordsetPtr spRSCopy;
_ConnectionPtr spCON;
try{
CREATEiNSTANCE(spCON,Connection);
spCON->ConnectionString = L"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Index.mdb;"
L"Persist Security Info=False";
spCON->Open( "", "", "", -1 );
CREATEiNSTANCE(spRS,Recordset)
spRS->PutRefActiveConnection( spCON );
spRS->Open("select STATIONID,STATNAME from Station", vtMissing, adOpenKeyset,
adLockBatchOptimistic, adCmdUnspecified); CREATEiNSTANCE(spRSCopy,Recordset)
spRSCopy->PutRefActiveConnection( spCON );
spRSCopy->Open("select STATIONID,STATNAME from Copy", vtMissing, adOpenKeyset,
adLockOptimistic, adCmdUnspecified);
while(spRS->adoEOF == false){
printf("StationID = %s StationName = %s \n", UC _bstr_t(RsITEM(spRS,"STATIONID")),
UC _bstr_t(RsITEM(spRS,"STATNAME")));
spRSCopy->AddNew();
RsITEM(spRSCopy,"STATIONID") = _bstr_t(UC _bstr_t(RsITEM(spRS,"STATIONID")));
RsITEM(spRSCopy,"STATNAME") = _bstr_t(UC _bstr_t(RsITEM(spRS,"STATNAME"))); spRSCopy->Update();
spRS->MoveNext();
}
spRS->Close();
spRSCopy->Close();
spCON->Close();
}
catch( _com_error &e){
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ")
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ")
+ _bstr_t(e.Description());
MessageBox(0,bs,bstrSource, MB_OK);
}
}
#undef UC
Open(
"driver={SQLServer};Server=127.0.0.1;DATABASE=vckbase;UID=sa;PWD=139","","",adModeUnknown
);
读写ini的C++类 http://www.vckbase.com/code/downcode.asp?id=2462