欧美一级色视频,簧片在线免费看,美日韩在线,成人观看网站a,亚洲欧美在线一区二区,欧美操穴,欧美综合专区

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

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

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

2015.09.10 | 679閱讀 | 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ù)庫(kù)字符串代碼: 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)論

平定县| 罗源县| 石城县| 东至县| 拉孜县| 武陟县| 武清区| 临清市| 丹凤县| 乾安县| 楚雄市| 德格县| 绥芬河市| 萍乡市| 三亚市| 和林格尔县| 连江县| 凉山| 永福县| 蒙自县| 鄄城县| 全南县| 建水县| 敖汉旗| 邵阳市| 铅山县| 桑植县| 富裕县| 出国| 澄迈县| 固始县| 宝山区| 墨竹工卡县| 林口县| 蒙城县| 临沭县| 昌都县| 东台市| 聂荣县| 邹平县| 长汀县|