我想从我的表中读取一个 int 值。但我遇到了错误,这是我的代码。请帮我编辑我的代码。
sqlc = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
string username = HttpContext.Current.User.Identity.Name.ToString();
cmd.CommandText = @"SELECT RemainedCharge "
+ " FROM aspnet_Users "
+ " WHERE UserName = @UserName ";
cmd.Parameters.Add(new SqlParameter("@UserName", username));
//string RemainedCharge;
sqlc.Open();
SqlDataReader rdr = cmd.ExecuteReader();
// loop over all rows returned by SqlDataReader
while(rdr.Read())
{
RemainedChargeLbl.Text=rdr.GetString(0);
}