C# 如何在c中更新我的数据库访问权限#
这是我的密码C# 如何在c中更新我的数据库访问权限#,c#,sql,sql-server-2008,tsql,C#,Sql,Sql Server 2008,Tsql,这是我的密码 private void btnUpdate_Click(object sender, EventArgs e) { byte[] imgbyte = null; FileStream fs = new FileStream(this.txtImageLocation.Text, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); imgbyte = br.Read
private void btnUpdate_Click(object sender, EventArgs e)
{
byte[] imgbyte = null;
FileStream fs = new FileStream(this.txtImageLocation.Text, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
imgbyte = br.ReadBytes((int)fs.Length);
connection.Open();
string query = "update [Student] set [StudentID] = @StudentID, [Lastname] = @Lastname, [Firstname] = @Firstname, [Image] = @Image where [NID] = '" +lblNID.Text+ "' "; //NID column is my primary key and auto increment
OleDbCommand command = new OleDbCommand(query, conn);
command.Parameters.AddWithValue("@StudentID", txtStudentID.Text);
command.Parameters.AddWithValue("@Lastname", txtStudentLN.Text);
command.Parameters.AddWithValue("@Firstname", txtStudentFN.Text);
command.Parameters.Add(new OleDbParameter("@Image", imgbyte));
}
每次我试图在不更改图片的情况下进行更新时,都会出现错误:空路径是不合法的
当我试图更改图片时,在条件表达式中出现了数据类型不匹配的错误
有人能帮我吗?提前谢谢
这是桌子
能否请您分享有关列类型为的表结构的详细信息?此错误到底出现在哪一行?您已经使用了所有更新列的参数,为什么不将其用于where子句?图像列的数据类型是什么?在哪一行代码中出现错误?在
string query=update[Student]set[StudentID]..的开头缺少一个引号。
在update
->“更新
如果您正在进行更新并且不想更改图片,请不要更新图片字段!请您也分享一下关于列类型为的表结构的详细信息,这个错误到底出现在哪一行?您已经使用了所有更新列的参数,为什么不也使用where子句呢?图像列的数据类型是什么?在哪一行代码中出现错误?您在string query=update[Student]set[StudentID]..的开头缺少一个引号。
在update
->update
之前放置一个引号。如果您正在进行更新,并且不想更改图片,请不要更新图片字段!