private void button2_Click(object sender, EventArgs e)
{
//OpenFileDialog opf = new OpenFileDialog();
if (textBox2.Text == "" || comboBox1.Text == "" || textBox3.Text == "")
{
MessageBox.Show("请输入完整的信息!", "提示");
}
else
{
FileStream fst = new FileStream(textBox2.Text, FileMode.Open, FileAccess.Read);
byte[] by = new Byte[fst.Length];
fst.Read(by, 0, (int)fst.Length);
if (fst.Length == 0)
{
MessageBox.Show("文件为空!", "提示");
}
else
{
try
{
DataSet ds = new DataSet();
sqlDataAdapter2.Fill(ds, "content");
DataTable MyTable = ds.Tables[0];
DataRow MyRow = MyTable.NewRow();
MyRow["ProjectName"] = comboBox1.Text;
MyRow["Type"] = textBox4.Text;
MyRow["Title"] = textBox3.Text;
FileStream fs = new FileStream(textBox2.Text, FileMode.OpenOrCreate, FileAccess.Read);
byte[] MyData = new byte[fs.Length];
fs.Read(MyData, 0, (int)fs.Length);
fs.Close();
MyRow["ProjectContent"] = MyData;
MyTable.Rows.Add(MyRow);
sqlDataAdapter2.Update(ds, "content");
ds.AcceptChanges();
MessageBox.Show("成功存储!", "提示");
sqlDataAdapter2.Dispose();
this.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"错误提示");
}
}
}
}