#include <iostream> #include <stdio.h> #include <ICRSINT.H> #include <string.h> #import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "adoEOF") using namespace std; int main() {
CoInitialize(NULL); _RecordsetPtr m_pRecordset("ADODB.Recordset"); _ConnectionPtr m_pConnection("ADODB.Connection"); _bstr_t bstrSQL("select * from Tstudent;"); m_pConnection.CreateInstance("ADODB.Connection"); _bstr_t strConnect= "Provider=SQLOLEDB;Server=localhost;Database=mydatabase;uid=sa; pwd=admin";
m_pConnection->Open(strConnect,"","",adModeUnknown); if(m_pConnection==NULL) printf("conn error"); printf("conn ok\n"); system("pause"); return 0;
}
|
请发表评论