我想从数据库表中更新1个字段。如您所见,我正在尝试将值vrednost
分配给atrName
。我的错误发生在这一行:R.+atrName+=
如何正确写入该行?
public bool UpdatePlayerVV(string ime, string atrName, string vrednost)
{
DataSet1.PlayersDataTable his = Adapter.GetDatapl2(ime);
if (his.Count == 0)
{
return false;
}
DataSet1.PlayersRow R = his[0];
if (vrednost == null) { }
else R.+atrName+= vrednost;
int rowsAffected = Adapter.Update(R);
return rowsAffected == 1;
}
答案 0 :(得分:0)
var nw = ConfigurationManager.ConnectionStrings["CONNECTION_STRING"];
int count = 0;
using (var connection = new SqlConnection())
{
connection.ConnectionString = nw.ConnectionString;
var cmd = connection.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update Players set...."
connection.Open();
count = cmd.ExecuteNonQuery();
}
答案 1 :(得分:0)
您是否尝试过以下操作?
R[atrName] += vrednost;
答案 2 :(得分:0)
尝试使用onli括号
[R [变量] = someValue中;