91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

C#通過(guò)ODBC鏈接SQLServer數(shù)據(jù)庫(kù)

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Data;
using?System.Data.Odbc;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;

namespace?ODBC
{
????class?Program
????{
????????static?void?Main(string[]?args)
????????{
????????????Console.WriteLine(“請(qǐng)輸入鏈接字符串“);
????????????string?config?=?Console.ReadLine();
????????????Connect(config);
????????????Console.ReadLine();
????????}

????????public?static?void?Connect(string?config)
????????{
????????????try
????????????{
????????????????//DSN:mylink數(shù)據(jù)源的名稱?UID:sql?server登錄時(shí)的身份sa?PWD:登錄時(shí)的密碼123456
????????????????//生成連接數(shù)據(jù)庫(kù)字符串
????????????????if?(String.IsNullOrEmpty(config))
????????????????{
????????????????????config?=?“server=localhost;DSN=SQL_SERVER;UID=COMOSUSER;PWD=******“;
????????????????}
????????????????//定義SqlConnection對(duì)象實(shí)例

????????????????OdbcConnection?connection?=?new?OdbcConnection(config);
????????????????string?sql?=?“select?name?from?sysobjects?where?xtype=‘U‘“;

????????????????OdbcDataAdapter?odbcAdapter?=?new?OdbcDataAdapter(sql?connection);
????????????????DataSet?result?=?new?DataSet();
????????????????odbcAdapter.Fill(result);
????????????????foreach?(DataTable?dataTable?in?result.Tables)???//遍歷所有的datatable
????????????????{
????????????????????foreach?(DataRow?dataRow?in?dataTable.Rows)???///遍歷所有的行
????????????????????????foreach?(DataColumn?dataColumn?in?dataTable.Columns)???//遍歷所有的列
????????????????????????????Console.WriteLine(“{0}{1}{2}“?dataTable.TableName?dataColumn.ColumnName?dataRow[dataColumn]);
????????????????????//表名列名單元格數(shù)據(jù)
????????????????}

????????????}
????????????catch?(System.Exception?e)
????????????{
????????????????Console.WriteLine(e.ToString());
????????????}
????????}

????}
}

評(píng)論

共有 條評(píng)論

相關(guān)資源