ODBC Driver for Oracle//For the current Oracle ODBC Driver from Microsoft: strConnect = _T("Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;" "Uid=MyUsername;Pwd=MyPassword;");//For the older Oracle ODBC Driver from Microsoft: strConnect = _T("Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;" "Uid=myUsername;Pwd=myPassword;");
2、用ADO我不太熟,但我知道它是对数据库直接操作,数据处理速度较快,但比较烦。由于不熟,就不多说了
2.HRESULT hr;
try {
hr = m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象if(SUCCEEDED(hr))
{
hr = m_pConnection->Open(
"Provider=MSDAORA;Data Source=serverName;User ID=userName; Password=userPassword;","","",adModeUnknown);
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage; errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);///显示错误信息 }
strConnect = _T("Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;"
"Uid=MyUsername;Pwd=MyPassword;");//For the older Oracle ODBC Driver from Microsoft:
strConnect = _T("Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;"
"Uid=myUsername;Pwd=myPassword;");
2.HRESULT hr;
try {
hr = m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象if(SUCCEEDED(hr))
{
hr = m_pConnection->Open(
"Provider=MSDAORA;Data Source=serverName;User ID=userName; Password=userPassword;","","",adModeUnknown);
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage; errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);///显示错误信息 }
ADO第一次亲密接触 -- ADO开发实践之一我们在程序中是这样用的:
hr=m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象
if (SUCCEEDED(hr))
{
hr=m_pConnection->Open("Provider=OraOLEDB.Oracle;DataSource=Multi;User ID=multi;password=multi","","",adModeUnknown);//连接数据库
}其中DataSource是数据库名称,UserID和password分别是数据库的用户名和密码,你可以试试。
也可以用OCI连接,安装好oracle后它有c语言的例程。
还可以用内嵌编程的方式。