c# 从零到精通 读取连接数据库-并将数据填入dataGridView控件中

c# 从零到精通 读取连接数据库-并将数据填入dataGridView控件中
using System;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Test01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(“server=MRC-8CF94303A82\MRNET;database=db_16;uid=sa;pwd=111”);
SqlDataAdapter sda = new SqlDataAdapter(“select * from tb_emp”,conn);
DataSet ds = new DataSet();
sda.Fill(ds,“emp”);
dataGridView1.DataSource = ds.Tables[“emp”];
}
}
}

你可能感兴趣的:(数据库,c#,java)