查询执行后,我需要获取的结果是 UserNames 部分。
我收到一个错误:无法使用 [] 将索引应用于“方法组”类型的表达式
public class ProcessInput
{
string connectionString = (string)ConfigurationSettings.AppSettings["myConString"];
private string msg_arr;
string username = null;
private void MooseSeenInput(string MobileNo, string Date, string odd, params Array[] msg_arr)
{
SqlConnection conn = new SqlConnection(myConString);
conn.Open();
SqlCommand com = new SqlCommand("SELECT * FROM Users as users WHERE UserName=@UserName AND State!='1' AND State!='4'", conn);
com.Parameters.AddWithValue("@UserName", UserName);
// com.ExecuteNonQuery();
using (SqlDataReader reader = com.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
String UserNames = (reader.Read["users"]);
}
}
}
}
}
错误发生在以下行:
String UserNames = (reader.Read["users"]);