using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Da
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Da
namespace WindowsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection("Server=localhost\\SQLEXPRESS;Database=开销;User ID=sa;Password=110;Trusted_Connection=False");
private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter da=new SqlDataAdapter ( "select * from 账本 ",con);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
ds.Tables.Add(dt);
da.Fill(ds.Tables[0]);
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "xml文件|*.xml|所有文件 (*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
ds.WriteXml(sfd.FileName);
MessageBox.Show("ok");
}
}
private void button2_Click(object sender, EventArgs e)
{
DataSet df = new DataSet();
OpenFileDialog pf =new OpenFileDialog();
pf.Filter = "xml文件|*.xml|所有文件 (*.*)|*.*";
if(pf.ShowDialog()==DialogResult.OK)
{
df.ReadXml(pf.FileName);
dg.DataSource = df.Tables[0];
MessageBox.Show("ok");
}
}
}
}