时间:2021-07-01 10:21:17 帮助过:34人阅读
2、通过IBM提供的IBM.data.DB2.DLL
string strSql = @"select phone_no from no_store where id<5"; string strConn = "Database=数据库名;UID=用户名;PWD=密码;"; using (DB2Connection conn = new DB2Connection(strConn)) { DB2Command cmd = new DB2Command(strSql, conn); try { conn.Open(); DB2DataAdapter adp = new DB2DataAdapter(cmd); DataSet ds = new DataSet(); adp.Fill(ds); DataTable dt = ds.Tables[0]; if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { Console.WriteLine("电话" + i + ":" + dt.Rows[i][0].ToString()); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.Read();
C#连接db2数据库
标签:select pen sele dad ++ 用户 ESS new exce