.Net中如何连接到ODBC数据源
|
源代码网整理以下1.下载ODBC.NET (FrameWork 2.0以上默认未安装) 源代码网整理以下下载地址:http://www.microsoft.com/downloads/details.aspx?familyid=6ccd8427-1017-4f33-a062-d165078e32b1 源代码网整理以下2.创建项目,添加Microsoft.Data.ODBC.dll 引用 源代码网整理以下3.cs代码如下: 源代码网整理以下using System.Data; 源代码网整理以下SqlServer: 源代码网整理以下OdbcConnection cn; 源代码网整理以下 MyString="Select * from Customers"; 源代码网整理以下 cn= new OdbcConnection("Driver={SQL Server};Server=mySQLServer;UID=sa; 源代码网整理以下 cmd=new OdbcCommand(MyString,cn); 源代码网整理以下 MessageBox.Show("Connected"); 源代码网整理以下 cn.Close(); 源代码网整理以下OLEDB JET: 源代码网整理以下OdbcConnection cn; 源代码网整理以下 MyString="Select * from Titles"; 软件开发网 www.mscto.com 源代码网整理以下 cn= new OdbcConnection("Driver={Microsoft Access Driver (*.mdb)}; 源代码网整理以下 cn.Close(); 软件开发网 www.mscto.com
源代码网整理以下 源代码网整理以下OdbcConnection cn; 源代码网整理以下 MyString="Select * from Customers"; 源代码网整理以下 cn= new OdbcConnection("Driver={Microsoft ODBC for oracle};Server=myOracleServer; 源代码网整理以下 cmd=new OdbcCommand(MyString,cn); 源代码网整理以下 MessageBox.Show("Connected"); 源代码网整理以下 cn.Close(); 源代码网整理以下 源代码网整理以下 源代码网整理以下OdbcConnection cn; 源代码网整理以下 MyString="Select * from Customers"; 源代码网整理以下 cn= new OdbcConnection("dsn=myDSN;UID=myUid;PWD=myPwd;"); 源代码网整理以下 cmd=new OdbcCommand(MyString,cn); 源代码网整理以下 cn.Open(); 源代码网整理以下 cn.Close(); 源代码网推荐 源代码网供稿. |
