Rabu, 15 Juli 2009

SINTAK DRIVER ADO

ODBC Driver for dBASE

strConnection = _T("Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;"

"Dbq=c:\\DatabasePath;");

example:

CString strQuery = _T("Select Name, Address From Clients.dbf");

ODBC Driver for Excel

strConnection = _T("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;"

Dbq=C:\\DatabasePath\\DBSpreadSheet.xls;DefaultDir=c:\\databasepath;");

ODBC Driver for Text

strConnection = _T("Driver={Microsoft Text Driver (*.txt; *.csv)}; "Dbq=C:\DatabasePath\coba.txt;Extensions=asc,csv,tab,txt;");

example:

CString strQuery = _T("Select Name, Address From Clients.csv");

Visual FoxPro

strConnection = _T("Driver={Microsoft Visual Foxpro Driver};UID=;"

ourceType=DBC;SourceDB=C:\\DatabasePath\\MyDatabase.dbc;Exclusive=No");

parameter by DBF

strConnection = _T("Driver={Microsoft Visual Foxpro Driver};UID=;"

"SourceType=DBF;SourceDB=C:\\DatabasePath\\MyDatabase.dbc;Exclusive=No");

ODBC Driver for Access

strConnection = _T("Driver={Microsoft Access Driver (*.mdb)};"

"Dbq=c:\\DatabasePath\\dbaccess.mdb;Uid=;Pwd=;");

ATAU

strConnection = _T("Driver={Microsoft Access Driver (*.mdb)};"

"Dbq=C:\\VC Projects\\ADO\\Samples\\AdoTest\\dbTestSecurity.mdb;"

"SystemDB=C:\\Program Files\\Microsoft Office\\Office\\SYSTEM.mdw;"

"Uid=Carlos Antollini;Pwd=carlos");

ATAU

strConnection = _T("Driver={Microsoft Access Driver (*.mdb)};"

"Dbq=C:\\VC Projects\\ADO\\Samples\\AdoTest\\dbTestSecurity.mdb;"

"SystemDB=C:\\Program Files\\Microsoft Office\\Office\\SYSTEM.mdw;");

if(pDB.Open(strConnection, "DatabaseUser", "DatabasePass"))

{

DoSomething();

pDB.Close();

}


ODBC Driver for SQL SERVER :

strConnection = _T("Driver={SQL Server};Server=MyServerName;"

"Trusted_Connection=no;"

"Database=MyDatabaseName;Uid=MyUserName;Pwd=MyPassword;");

For Trusted Connection security (Microsoft Windows NT integrated security):

strConnection = _T("Driver={SQL Server};Server=MyServerName;"

"Database=myDatabaseName;Uid=;Pwd=;");


For the older Oracle ODBC driver from Microsoft:

strConnect = _T("Driver={Microsoft ODBC Driver for Oracle};"

"ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;");

ODBC Driver for MySQL

If you want to connect to a local database, you can use a connection string like the following:

strConnect = _T("Driver={MySQL ODBC 3.51 Driver};Server=localhost;"

"Database=MyDatabase;User=MyUserName;Password=MyPassword;Option=4;");

Tidak ada komentar: