xml窗体
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Multiselect = true;
fileDialog.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
//选择当前打开文件目录
fileDialog.Title = "请选择文件";
//弹出窗体名称
fileDialog.Filter = "xml文件|.xml";
//默认文件类型
if (fileDialog.ShowDialog() == DialogResult.OK)
{
string file = fileDialog.FileName;
}
else
{
MessageBox.Show("已取消");
}
}
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
string strconn = "Data Source=.; Integrated Security=SSPI; Initial Catalog=students";
SqlConnection conn = new SqlConnection(strconn);
string str = "select * from 学生表";
SqlCommand cmd = new SqlCommand(str, conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
conn.Close();
}