zoukankan      html  css  js  c++  java
  • 菜鸟学习C#数据库实例练习使用SqlDataReader,SqlCommand SqlConnection

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;

    namespace ConsoleApplication3
    {
        class Program
        {
            static void Main(string[] args)
            {
               string strCon="server=(local);database=northwind;uid=sa;pwd=123456";
                string select="SELECT ContactName,CompanyName FROM Customers";
                SqlConnection conn=new SqlConnection(strCon);
                conn.Open();
                SqlCommand cmd = new SqlCommand(select, conn);
                SqlDataReader aReader = cmd.ExecuteReader();
                while (aReader.Read())
                    Console.WriteLine("'{0}' from {1}", aReader.GetString(0), aReader.GetString(1));
                aReader.Close();
                conn.Close();
               

               
               
                Console.ReadLine();


            }
          
          
        }
      
    }

  • 相关阅读:
    程序从命令行接收多个数字,求和之后输出结果。
    动态规划(1)
    软件工程个人作业(4)
    冲刺2 01
    构建之法
    水王
    大道至简第七章读后感
    构建之法03
    团队冲刺第四天
    团队冲刺第三天
  • 原文地址:https://www.cnblogs.com/finallyliuyu/p/1515280.html
Copyright © 2011-2022 走看看