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

首頁 > 學院 > 開發設計 > 正文

ADO.NET中的sql連接

2019-11-18 16:51:55
字體:
來源:轉載
供稿:網友

using System.Data;            // Use ADO.NET namespace
using System.Data.SqlClient; 

 SqlConnection thisConnection = new SqlConnection(
            @"Data Source=GY; Initial Catalog=northwind;uid=sa;passWord=datadog"); //先建立連接
 thisConnection.Open();//打開連接
         SqlCommand thisCommand = thisConnection.CreateCommand();//直接指定conn的command
也可以這樣        //  SqlCommand cmd = new SqlCommand();
       //  cmd.Connection = thisConnection;
cmmand的sql命令        
thisCommand.CommandText = "SELECT CustomerID, CompanyName from Customer";
         SqlDataReader thisReader = thisCommand.ExecuteReader();//sqldatareader不可以用new 必須直接與command關聯
//用reader讀出表
         while (thisReader.Read())
         {
            // Output ID and name columns
            Console.WriteLine("/t{0}/t{1}",
               thisReader["CustomerID"], thisReader["CompanyName"]);
         // Close reader 用完要關閉
         thisReader.Close();

         // Close connection
         thisConnection.Close ()

http://m.survivalescaperooms.com/redcar/archive/2006/11/23/569859.html


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青州市| 三原县| 莱阳市| 陕西省| 徐水县| 西乌珠穆沁旗| 时尚| 五大连池市| 汉川市| 定兴县| 通山县| 高陵县| 柏乡县| 滨州市| 凯里市| 寻乌县| 新平| 澄城县| 包头市| 山丹县| 上高县| 噶尔县| 彰武县| 会理县| 巴楚县| 保德县| 团风县| 麻城市| 中牟县| 含山县| 湖口县| 舟曲县| 高邑县| 本溪| 镇康县| 潍坊市| 富锦市| 富蕴县| 沁水县| 积石山| 永德县|