using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Ex04_7
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            //生成连接数据库字符串
            string ConStr = "server=(local);user id=myzf;pwd=123456;database=MysqlData";
            //定义SqlConnection对象实例  
            SqlConnection con = new SqlConnection(ConStr);
            //定义Select查询语句
            string SqlStr = "select * from 应付账";
            SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
            DataSet ds = new DataSet();    //定义DataSet对象实例
            ada.Fill(ds);
            //连接数据表格，显示数据  
            this.dataGridView1.DataSource = ds.Tables[0].DefaultView;

        }
    }
}
