多做题,通过考试没问题!

微软认证考试

睦霖题库>其他计算机考试>微软认证考试

You are creating a Web Form. You write the following code segment to create a SqlCommand object. SqlConnection conn = new.SqlConnection(connString); conn.Open( ); SqlCommand cmd = conn.CreateCommand( ); cmd.CommandText = “select cont(*) from Customers”; You need to display the number of customers in the Customers table. Which two code segments can you use to achieve this goal? ()

  • A、object customerCount = cmd.ExecuteScalar();lblCompanyName.Text = customerCount.ToString();
  • B、int customerCount = cmd.ExecuteNonQuery();lblCompanyName.Text = customerCount.ToString();
  • C、SqlDataReader dr = cmd.ExecuteReader();dr.Read();lblCompanyName.Text = dr[0].ToString();
  • D、SqlDataReader dr = cmd.ExecuteReader();dr.Read();lblCompanyName.Text = dr.ToString();
正确答案:A,C
答案解析:
进入题库查看解析

微信扫一扫手机做题