asp.net+access去更新但是更新不了,但能删除和insert{sql 语句没有错}
我用asp.net+access去更新但是更新不了,但能删除和insert{sql 语句没有错}
代码如下
//添加删除更新
public int Excount(string commandText, params OleDbParameter[] paras)
{
OleDbCommand cmd = new OleDbCommand(commandText, oledbConn );
try
{
foreach (OleDbParameter p in paras)
{
cmd.Parameters.Add(p);
}
oledbConn.Open();
return (int)cmd.ExecuteNonQuery();
}
catch (OleDbException ex)
{
Console.WriteLine("In Main catch block. Caught: {0}", ex.Message);
Console.WriteLine("Inner Exception is {0}", ex.InnerException);
throw ex;
}
finally
{
cmd.Dispose();
oledbConn.Close();
}
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Updatefriend(friend fri)
{
string sql = "update friend set friendname=@friendname,friendurl=@friendurl where friendid=@friendid";
OleDbParameter[] parameters = {
new OleDbParameter("@friendid", OleDbType.Integer,4),
new OleDbParameter("@friendname", OleDbType.VarChar,50),
new OleDbParameter("@friendurl", OleDbType.VarChar,50)};
parameters[0].Value = fri.friendid;
parameters[1].Value = fri.friendname;
parameters[2].Value = fri.friendurl;
return sqlhelp .Excounts(sql.ToString (), parameters);
}
sss.cs
int a = int.Parse(this.GridView1.DataKeys[e.RowIndex]["friendid"].ToString());
string name = ((GridView1.Rows[e.RowIndex].Cells[0].FindControl("TextBox1")) as TextBox).Text.ToString();
string count = ((GridView1.Rows[e.RowIndex].Cells[1].FindControl("TextBox2")) as TextBox).Text.ToString();
friend vov=new friend();
vov.friendname =name ;
vov.friendid = a;
vov.friendurl =count ;
Bllfriend.Updatefriend(vov);//更新
请问哪位高人指点一下啊 不是数据库权限问题