System.Data.SqlClient.SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
System.Data.SqlClient.SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
long MachineGroupID = Convert.ToInt64(Request.QueryString["node"]);
dataCommand.CommandText = "UPDATE [MachineGroups] SET [MachineGroupName]=@MachineGroupName,[MachineGroupDesc]=@MachineGroupDesc WHERE [MachineGroupID]= @MachineGroupID";
//add our parameters to our command object
dataCommand.Parameters.AddWithValue("@MachineGroupName", MachineGroupName);
dataCommand.Parameters.AddWithValue("@MachineGroupDesc", MachineGroupDesc);
dataCommand.Parameters.AddWithValue("@MachineGroupID", MachineGroupID);
dataConnection.Open();
dataCommand.ExecuteNonQuery();
dataConnection.Close();
在这里,MachineGroups表有一个名为“tval”的列,该列首先插入了用户值,然后在更新时应该将其设置为SQl创建时设置的默认值。
例如:
[tval] [int] NOT NULL DEFAULT ((2147483647))
这是列创建的方式,现在我想在更新时放置值2147483647。
另外,我不能固定值为“2147483647”,因为它可能会更改。
有什么建议吗?
谢谢。