数据源创建及数据库操作

以下为innosetup脚本 mysql数据源

 

;配置ODBC数据源

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/TEST;valuetype:string;valuename:"server";valued

 

ata:"localhost";flags:uninsdeletekey;

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/TEST;valuetype:string;valuename:"UID";valuedata

 

:"root";flags:uninsdeletekey;

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/TEST;valuetype:string;valuename:"PWD";valuedata

 

:"123456";flags:uninsdeletekey;

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/TEST;valuetype:string;valuename:"DATABASE";valu

 

edata:"vhost";flags:uninsdeletekey;

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/TEST;valuetype:string;valuename:"OPTION";valued

 

ata:"3147784";flags:uninsdeletekey;

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/TEST;valuetype:string;valuename:"port";valuedat

 

a:"8306";flags:uninsdeletekey;

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/TEST;valuetype:string;valuename:"Driver";valued

 

ata:"C:/WINDOWS/system32/myodbc5.dll";flags:uninsdeletekey;

Root:HKLM;subkey:SOFTWARE/ODBC/ODBC.INI/ODBC Data 

 

Sources;valuetype:string;valuename:"IISLog";valuedata:"MySQL ODBC 5.1 

 

Driver";flags:uninsdeletevalue;

数据库操作:
#import "C://Program Files//Common Files//System//ADO//msado15.dll" / no_namespace rename("EOF", "EndOfFile") int _tmain(int argc, _TCHAR* argv[]) { CoInitialize(NULL); _ConnectionPtr pMyConnect = NULL; _RecordsetPtr pRecordset = NULL; HRESULT hr = E_FAIL; try { pMyConnect.CreateInstance(__uuidof(Connection)); pMyConnect->Open(TEXT("DSN=TEST;"), TEXT(""), TEXT(""), NULL); WCHAR szSQL[1024] = {0}; WCHAR szIdentify[256] = {0}; _stprintf(szSQL, TEXT("select id,name from people")); pRecordset.CreateInstance(__uuidof(Recordset)); pRecordset->Open(szSQL, _variant_t((IDispatch *)pMyConnect,true), adOpenKeyset, adLockOptimistic, adCmdText); VARIANT vtId,vtName;// while(pRecordset->EndOfFile == VARIANT_FALSE) { pRecordset->Fields->GetItem(_bstr_t("id"))->get_Value(&vtId); pRecordset->Fields->GetItem(_bstr_t("name"))->get_Value(&vtName); …… if (SUCCEEDED(hr)) { pRecordset->MoveNext(); } else { wprintf(L"failed "); break; } pRecordset->Close(); pMyConnect->Close(); } catch (_com_error &e) { Log(); } CoUninitialize(); cout<<"输入任意键结束"<<endl; getchar(); return 0; } 

 

你可能感兴趣的:(数据库,mysql,server,脚本,null,database)