1.access链接字符串
hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=test.mdb","","",adModeUnknown);//连接数据库
//上面一句中连接字串中的Provider是针对Access2000环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51; }
2. sql server 2000 链接字符串
strConn.Format("driver={SQL Server};server=%s;database=%s;uid=%s;pwd=%s;",strServer,strDataBase,strUID,strPWD);
// {"driver={SQL Server};server=172.16.12.182;database=bd_fangshi;uid=sa;pwd=sa;"}
3. oracle链接字符串
分两种情况:
其一.对dsn建立链接
strConn.Format("Provider=ORAOLEDB.ORACLE.1;User ID=%s;Data Source=%s;Password=%s;Persist Security Info=True",strUID,strServer,strPWD);//;Persist Security Info=True
/*{"Provider=ORAOLEDB.ORACLE.1;User ID=tdqs;Data Source=xe;Password=tdqs;Persist Security Info=True"}*/
其二.使用ip建立链接
strConn.Format("Provider=ORAOLEDB.ORACLE.1;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SERVICE_NAME=%s)));User Id=%s;Password=%s",
strIP, strPort, strDb, strUser, strPwd);
/*{"Provider=ORAOLEDB.ORACLE.1;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.12.182)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)));User Id=tdqs;Password=tdqs"}*/
作者:滴水成河
2010.6.2