Improper result

  • Thread starter Thread starter Jackson_1990
  • Start date Start date
J

Jackson_1990

Guest
Hi,

I have the code like

cmd = new SqlCommand("select isnull(max_id,0) from (SELECT max(c_id) max_id FROM chat_tab where user_id=@user_id) q", conn);


int a = 0;

if (Int32.TryParse(lb_user_id.Text, out a))

cmd.Parameters.Add("@user_id", SqlDbType.Int).Value = a;

int cnt = Convert.ToInt32(cmd.ExecuteScalar());


if (cnt == 0)

{

return;

}

else

lb_c_id.Text = Convert.ToChar(cnt).ToString().Trim();

but it is getting relevant result properly. Why?


Many Thanks & Best Regards, Jackson Chen

Continue reading...
 
Back
Top