当我在C#中使用以下代码时...
int totalValue = 0;
int total = 0;
totalValue = int.Parse(Session["price"].ToString()) * int.Parse(Session["day"].ToString());
// This line causes the error
totalValue += Session["IsChauffeurUsed"].ToString().Equals("Yes", StringComparer.CurrentCultureIgnoreCase) ? 80 : 0;
Run Code Online (Sandbox Code Playgroud)
...我收到此错误:
无法使用实例引用访问成员'object.Equals(object,object)'; 用类型名称来限定它.
该错误表示什么?
我在这里问了一个问题.为什么我的数据不能插入我的数据库?我已经在SQL Server中创建了一个表.这是我的代码行供您参考.
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
SqlCommand cmd = new SqlCommand("Insert into CarTab(Brand,Model,Plate,Color,Service) Values (@brand,@model,@plate,@color,@year,@service)",conn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@brand", Label1.Text);
cmd.Parameters.AddWithValue("@model", Label2.Text);
cmd.Parameters.AddWithValue("@plate", Label3.Text);
cmd.Parameters.AddWithValue("@color", Label4.Text);
cmd.Parameters.AddWithValue("@year", Label5.Text);
cmd.Parameters.AddWithValue("@service", Label6.Text);
conn.Open();
cmd.ExecuteNonQuery();
}
Run Code Online (Sandbox Code Playgroud)
我的代码有问题吗?请帮助我.我被困在这里.谢谢.