我目前正在尝试选择所有用户名(用于测试的2个用户名)并将其传递到字符串数组中。
但是,到目前为止,我尝试过的所有结果都为我提供了第一个用户名,而不是所有用户名,因此我应该将它们传递给字符串数组,它可能只有1个值。
Label1.Text仅显示1个结果。
我尝试过executescalar,ExecuteNonQuery,executereader
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand())
{
con.Open();
string queries = "select username from loginuser";
using (SqlCommand biju = new SqlCommand(queries, con))
{
SqlDataReader sda = null;
sda = biju.ExecuteReader();
while (sda.Read())
{
Label1.Text = sda["username"].ToString();
}
/* sda = biju.ExecuteReader();
string a = Convert.ToString(sda);
Label1.Text = a; */
string message = string.Empty;
message = "list cleared for applicants to register again.";
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + message + "');", true);
// Three valid username/password pairs: Scott/password, Jisun/password, and Sam/password.
string[] users = new string[] { Label1.Text };