用vs2008 只会写C#的。。
C++不会啊
这是我C#的更新操作
public void EditAccount(Account bankAccount)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update BankAccount set ");
strSql.Append("AccountName=@AccountName,");
strSql.Append("CurrentAmount=@CurrentAmount,");
strSql.Append("IsCanceled=@IsCanceled");
strSql.Append(" where CardNo=@CardNo ");
SqlParameter[] parameters = {
new SqlParameter("@AccountName", SqlDbType.NVarChar,1024),
new SqlParameter("@CurrentAmount", SqlDbType.Decimal,9),
new SqlParameter("@IsCanceled", SqlDbType.Bit,1),
new SqlParameter("@CardNo", SqlDbType.NVarChar,100)};
parameters[0].Value = bankAccount.Cname;
parameters[1].Value = bankAccount.Csum;
parameters[2].Value = bankAccount.Cfreeze;
parameters[3].Value = bankAccount.Cid;
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
try
{
cmd.CommandType = CommandType.Text;
connection.Open();
cmd.Connection = connection;
cmd.CommandText = strSql.ToString();
foreach (SqlParameter parameter in parameters)
{
cmd.Parameters.Add(parameter);
}
int rows = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
}
catch (System.Data.SqlClient.SqlException e)
{
throw e;
}
}
}
}
select * from 你要查询的表 where id='+@id+' 是想要这样的么?