标签:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string connStr = "server=DESKTOP-QQGOIKH;uid=sa;pwd=123;database=t1"; private void Form1_Load(object sender, EventArgs e) { string sql = "select * from student"; SqlConnection conn = new SqlConnection(connStr); conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); sda.Fill(ds,"aa"); conn.Close(); DataTable dt= ds.Tables["aa"]; dataGridView1.DataSource = dt; } } }
标签:
原文地址:http://www.cnblogs.com/xiaz/p/5194977.html