为什么我的数据不能更新呢?(高手帮忙)
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 图书馆管理
{
public partial class DataAdd : Form
{
//private Container components;
private DataSet myDataSet;
// private BindingManagerBase myBind;
public DataAdd()
{
GetConnected();
InitializeComponent();
}
public void GetConnected()
{
try
{
string constr = "workstation id=;packet size=8000;integrated security=SSPI;data source=.;pe" +
"rsist security info=False;initial catalog=图书馆管理系统";
SqlConnection cn1 = new SqlConnection(constr);
string sq1 = "SELECT * from Storage";
myDataSet = new DataSet();
cn1.Open();
SqlDataAdapter myCommand = new SqlDataAdapter(sq1, cn1);
myCommand.Fill(myDataSet, "Storage");
cn1.Close();
}
catch (Exception e)
{
MessageBox.Show("连接错误!" + e.ToString(), "错误");
}
}
protected void saveclick(object sender, System.EventArgs e)
{
try {
if (T_BookNo.Text != "" && T_BookName.Text != "" && T_WriName.Text != "" && T_PubHouse.Text != "" && T_SavePlace.Text != "" && T_State.Text != "")
{
string constr = "workstation id=;packet size=8000;integrated security=SSPI;data source=.;pe" +
"rsist security info=False;initial catalog=图书馆管理系统";
SqlConnection cn1 = new SqlConnection(constr);
cn1.Open();
string strInsert=" UPDATE Storage Set BookName=T_BookName.Text,WriName=T_WriName.Text,PubHouse=T_PubHouse.Text,SavePlace=T_SavePlace.Text,State=T_State.Text,WHERE BookNo= ";
strInsert +=T_BookNo.Text;
SqlCommand inst=new SqlCommand( strInsert, cn1);
inst.ExecuteNonQuery();
cn1.Close();
}
else
{
MessageBox.Show("必须填满所有字段值!","错误!") ;
}
}
catch (Exception ed)
{
MessageBox.Show(("修改数据记录发生") + ed.ToString(),"错误!") ;
}
}
}
}
[[italic] 本帖最后由 purewqk 于 2007-12-26 21:49 编辑 [/italic]]
图书管理.jpg
(11.1 KB)