连接Oracle数据库
连接字符串:
连接驱动
Oracle公司提供的OleDB驱动,Provider需要根据实际情况修改,支持32bit与64bit,需要安装Oracle Data Provider for OLE DB.
连接字符串:
connectionString="provider=;Persist Security Info=False;User ID=UserName;Data Source=DataBase;Extended Properties='';Password=Password"
或
connectionString="provider=.1;Persist Security Info=False;User ID=UserName;Data Source=DataBase;Extended Properties='';Password=Password"
连接驱动MSDAORA
Microsoft公司提供的OleDB驱动,Provider需要根据实际情况修改,只支持32bit.
连接字符串:
connectionString="Provider=MSDAORA;Data Source=dataSource;User Id=userid;Password=password;"
或
connectionString="Provider=MSDAORA.1;Data Source=dataSource;User Id=userid;Password=password;"
连接
Microsoft公司提供,支持32bit与64bit,已建议作废.
连接字符串:
connectionString="Server=tnsnames;User Id=userid;Password=password;" providerName=""
对于各种数据库的连接方式,可参考
连接示例1:
- public static bool TestDB()
- {
- string connString = "Provider=MSDAORA;Data Source=dataSource;User Id=userid;Password=password;";
- try
- {
- DbConnection conn = new (connString);
- try
- {
- ();
- ();
- ("连接正常", "提示信息", , );
- return true;
- }
- catch (Exception e)
- {
- (, + , , );
- return false;
- }
- finally
- {
- ();
- }
- }
- catch (Exception e)
- {
- (, + , , );
- return false;
- }
- }
连接示例2:
- public static bool TestDB()
- {
- string connString = "Provider=MSDAORA;Data Source=dataSource;User Id=userid;Password=password;";
- try
- {
- using (DbConnection conn = new (connString))
- {
- ();
- ();
- ("连接正常", "提示信息", , );
- return true;
- }
- }
- catch (Exception e)
- {
- (, + , , );
- return false;
- }
- }