我用文本框读出了数据库数据.然后通过删掉文本框的信息.重新填写数据,点提交进行修改数据库内容..这样能实现吧..??
但我这样做修改不了啊..一点提交,文本框又变回原来的数据了!!怎么办啊?
但我这样做修改不了啊..一点提交,文本框又变回原来的数据了!!怎么办啊?
解决方案 »
- frameset导航 asp.net
- string 转换成 int 出错????????????????????
- vs2008中 ASP.NET用C#进行开发,发现GridView控件没有RowDataBound事件
- 显示投票比例
- 怎样用 SOAP Toolkit 发送 SOAP 消息???
- 简单明白地讲讲petshop4的多层应用是如何实现的:1)数据怎么取得
- 兼职合作
- 请问在ASP.NET MVC2中如何处理异常?
- 这个DataGrid为什么不能分页!!! 高分。
- 请问DataGrid的翻页功能是否还要自己编程实现?比如有书上写在OnPageIndexChanged中实现?
- 浏览器突然出现不到服务器了??
- 对数据库表进行更新需要作同步处理吗?
... Page_load...
{
if(!IsPostBack)
{
//绑定
}
}
protected void Button2_Click(object sender, EventArgs e)
{ int a;
int b;
int c;
if (this.CheckBox1.Checked)
a = 1;
else
a = 0;
if (this.CheckBox2.Checked)
b = 1;
else
b = 0;
if (this.CheckBox3.Checked)
c = 1;
else
c = 0;
string id = Request.QueryString["id"].ToString();
int messageid = Convert.ToInt32(id);
ClassLibrary.managepd clm = new ClassLibrary.managepd();
try
{
clm.updatebook(this.TextBox1.Text, this.TextBox2.Text, this.TextBox3.Text, this.TextBox4.Text, this.TextBox5.Text, this.TextBox6.Text, this.TextBox7.Text, this.TextBox8.Text, a, b, c, messageid);//调用类库中的UPDATEBOOK方法(就是用存储过程的方法) Response.Write(" <script language='javascript'>alert('修改成功!'); </script>");
}
catch (Exception )
{
Response.Write(" <script language='javascript'>alert('修改失败!'); </script>");
}
}
`````````````````````````````````````````````````````````````````````````````````````````````````````` UPDATEBOOK方法
public void updatebook(string bookname, string author, string publish, string publishdate, string isbn, string oldprice, string nowprice,string zaiyao,int tuijian,int isonframe,int ischeap,int id)
{
SqlConnection conn = new SqlConnection(common.Class1.con);
conn.Open();
SqlCommand com = new SqlCommand(common.Class1.updateb, conn);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@bookname", SqlDbType.VarChar, 50).Value = bookname;
com.Parameters.Add("@author", SqlDbType.VarChar, 50).Value = author;
com.Parameters.Add("@publish", SqlDbType.VarChar, 200).Value = publish;
com.Parameters.Add("@publishdate", SqlDbType.VarChar,50).Value = publishdate;
com.Parameters.Add("@isbn", SqlDbType.VarChar, 50).Value = isbn;
com.Parameters.Add("@oldprice", SqlDbType.VarChar, 50).Value = oldprice;
com.Parameters.Add("@nowprice", SqlDbType.VarChar, 50).Value = nowprice;
com.Parameters.Add("@zaiyao", SqlDbType.VarChar, 200).Value = zaiyao;
com.Parameters.Add("@tuijian", SqlDbType.Int,4 ).Value = tuijian;
com.Parameters.Add("@isonframe", SqlDbType.Int, 4).Value = isonframe;
com.Parameters.Add("@ischeap", SqlDbType.Int,4).Value = ischeap;
com.Parameters.Add("@id", SqlDbType.Int).Value = id;
SqlDataAdapter da = new SqlDataAdapter();
da.UpdateCommand = com;
com.ExecuteNonQuery();
conn.Close();
}