using System;
using System
using System
namespace ConsoleSqlConnection
{
/// <summary>
/// Class
/// </summary>
class SqlConnectionClass
{
/// <summary>
/// 應用程序的主入口點
/// </summary>
[STAThread]
static void Main(string[] args)
{
string strCon = @
SqlConnection MyCon = new SqlConnection(strCon);
// 打開SQL Server數據庫
try
{
MyCon
// 浏覽數據庫
string strSQL = @
SqlCommand MyCommand = new SqlCommand(strSQL
// 將檢索結果放入SqlDataReader中
SqlDataReader MyDataReader = MyCommand
Console
while (MyDataReader
{
Console
}
MyDataReader
}
catch (Exception ex)
{
Console
}
finally
{
// 使用完畢
MyCon
}
Console
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13640.html