Int32.TryParse() or (int?)command.ExecuteScalar()

后端 未结 7 2251
既然无缘
既然无缘 2020-12-18 20:14

I have a SQL query which returns only one field - an ID of type INT.

And I have to use it as integer in C# code.

Which way is faster and uses less memory?

7条回答
  •  被撕碎了的回忆
    2020-12-18 20:21

    if ((Int32)cmd.ExecuteScalar () ** 1) //en esta parece qu esta el error pero no lo veo
    {
        Response.Redirect("Default.aspx");
    }
    else
    {
        Response.Redirect("error.htm") ;
    }
    

提交回复
热议问题