99麻豆久久久国产免费福利精品,国产精品成人国产乱,玖玖操,手机看片169,国产精彩视频在线观看,午夜亚洲福利视频,国产伦乱视频

龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

c#—winForm連接sql--App.config

2015.09.10 | 621閱讀 | 0條評(píng)論 | 未命名

c#—winForm連接sql 1、首先創(chuàng)建App.config文件,例如: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings > <add key ="Default" value ="Default"/>?? //先添加key,value <add key ="Access" value ="Access"/> </appSettings> <connectionStrings > <add name="Default" connectionString="Data Source=.;User ID=sa;Password=sa;Initial Catalog=HHHH" providerName="System.Data.SqlClient" /> <add name="Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\aaaa.mdb" providerName="System.Data.OleDb" /> </connectionStrings> </configuration> 2、 (1).SQL獲取數(shù)據(jù)庫字符串代碼: string strCon = ConfigurationManager.ConnectionStrings["Default"].ToString(); (2).OleDb connectionSettings = ConfigurationManager.ConnectionStrings[connectionStrings]; DbProviderFactory provider = DbProviderFactories.GetFactory(connectionSettings.ProviderName); 3、string strCon = ConfigurationManager.ConnectionStrings["Default"].ToString(); SqlConnection con = new SqlConnection(); con.ConnectionString = strCon; con.Open(); string sql = "select aa as ID from taba"; SqlDataAdapter da = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); da.Fill(ds); //填充DataSet DataTable dt = ds.Tables[0]; ArrayList a = new ArrayList(); for (int i = 0; i < dt.Rows.Count; i++) { a.Add(dt.Rows[i][0].ToString()); }

贊 (

發(fā)表評(píng)論

乌拉特中旗| 庆阳市| 德昌县| 芜湖市| 九龙县| 南陵县| 博白县| 株洲县| 台中县| 汉川市| 龙江县| 河曲县| 中卫市| 墨江| 博罗县| 岢岚县| 建阳市| 奉贤区| 鞍山市| 关岭| 周宁县| 七台河市| 盘锦市| 诏安县| 天津市| 黎平县| 西林县| 吉隆县| 通山县| 邛崃市| 会昌县| 青浦区| 乌兰察布市| 阿拉善盟| 土默特右旗| 巴彦淖尔市| 天全县| 鲜城| 马关县| 新邵县| 锦州市|