แบบที่ 1
string C = "select COUNT(status)as st from test where Keyword = @Keyword";
SqlDataAdapter adapter = new SqlDataAdapter(C, connectionString);
adapter.SelectCommand.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = searchtextBox.Text;
DataTable table = new DataTable();
adapter.Fill(table);
label5.Text = "จำนวนแถวทั้งหมด: " + table.Rows[0]["st"].ToString();
แบบที่ 2
string C = "select status as st from test where Keyword = @Keyword";
SqlDataAdapter adapter = new SqlDataAdapter(C, connectionString);
adapter.SelectCommand.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = searchtextBox.Text;
DataTable table = new DataTable();
adapter.Fill(table);
label5.Text = "จำนวนแถวทั้งหมด: " + table.Rows.Count.ToString();