首页 > 数据库技术 > 详细

【C#学习笔记】读SQL Server2008

时间:2017-08-27 16:03:09      阅读:309      评论:0      收藏:0      [点我收藏+]
using System;
using System.Data.SqlClient;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            SqlConnection con = new SqlConnection("server=.\\sqlexpress;uid=sa;pwd=123456;database=stuDB");
            con.Open();

            SqlCommand com = con.CreateCommand();
            com.CommandText = "select * from stuInfo";

            SqlDataReader reader = com.ExecuteReader();

            while (reader.Read())
                Console.WriteLine(reader["stuName"].ToString() + reader["stuAge"].ToString() + reader["stuSex"].ToString());

            reader.Close();
            con.Close();
            Console.Read();
        }      
    }
}

 

【C#学习笔记】读SQL Server2008

原文:http://www.cnblogs.com/tiandsp/p/7440432.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!