国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

c#數(shù)據(jù)庫連接字符串集合

2023-05-09 18:58:23
字體:
供稿:網(wǎng)友

本文介紹了C#連接常用數(shù)據(jù)庫的常用方法,供大家進行設計數(shù)據(jù)庫程序時參考。

(一)常用連接:

(1)使用SqlConnection對象:

public void SqlConnectionOpen()
{
SqlConnection conn= new SqlConnection();
conn.ConnectionString = "user id=sa;password=;initial catalog=northwind;datasource=localhost;connect Timeout=20";
conn.Open();
}

(2)使用OleDbConnection對象:

public void OleDBConnectionOpen()
{
OleDBConnection conn = new OleDbconnection();
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:/Customer.mdb";
conn.Open();
}

(二)其它:

(1)ODBC連接Access本地數(shù)據(jù)庫

conGoodDay.Open("Driver={Microsoft Access Driver(*.mdb)};"+"Dbq=C:/a.mdb;"+
"Uid=Admin;"+"Pwd=;");

(2)ODBC連接Access系統(tǒng)數(shù)據(jù)庫

conGoodDay.Open("Driver={Microsoft Access Driver(*.mdb)};"+"Dbq=C:/a.mdb;"+
"SystemDB=Admin;"+"Pwd=;");

(3)ODBC連接Access系統(tǒng)數(shù)據(jù)庫

conGoodDay.Open("Driver={Microsoft Access Driver(*.mdb)};"+"Dbq=//server/share/a.mdb;");

(4)ODBC連接Excel系統(tǒng)數(shù)據(jù)庫

conGoodDay.Open("Driver={Microsoft Access Driver(*.xls)};"+"DriverId=790;"+
"Dbq=C:/a.xls;"+"DefaultDir=c:/somepath;");

(5)ODBC連接Oracle系統(tǒng)數(shù)據(jù)庫

conGoodDay.Open("Driver={Microsoft ODBC for oracle};"+"Server=OracleServer.world;"+
"Uid=Admin;"+"Pwd=password;");

(6)ODBC連接Sql Servr

conGoodDay.Open("Driver={Sql Server};"+"Server=myServer;"+"Database=myDatabaseName;"
"Uid=Admin;"+"Pwd=password;");

(7)ODBC連接Visual FoxPro

conGoodDay.Open("Driver={Microsoft Visual FoxPro Driver};"+
"SourceType=DBC;"+"SourceDB=c:a.dbc;"+"Exclusive=No;");

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 泸州市| 赤峰市| 桃园市| 景宁| 邹城市| 育儿| 邹平县| 古蔺县| 驻马店市| 湄潭县| 威信县| 东城区| 罗城| 班玛县| 禄劝| 杂多县| 安宁市| 江都市| 水富县| 沽源县| 长沙市| 措美县| 务川| 新竹市| 镇巴县| 晴隆县| 和顺县| 怀远县| 乐陵市| 襄汾县| 扎鲁特旗| 邓州市| 扶沟县| 衢州市| 芮城县| 阳江市| 南漳县| 泗洪县| 福安市| 隆回县| 延津县|