using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WinFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnRead_Click(object sender, EventArgs e)
{
string connectionString = "server=.;database=sqlconnectiondemo;uid=sa;pwd=886566";
SqlConnection conn = new SqlConnection(connectionString);
string sql = "select count(*) from dbconnectiondemotable";
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
string result =Convert.ToString( comm.ExecuteScalar());
this.label1.Text = "查询到的总人数是:"+result;
Console.WriteLine(result);
}
}
}