SqlDataReader is not working - does not read data
Posted on 2013-11-13
When I debug it, it pass the loop while(readerOne.Read()). It never enter into this loop even though there is data.
What am I missing? Hopefully, I can get some assistance soon. It appears no one is out there because of no attention to my previous posts. I deleted them because I eventually find a solution on stackoverflow.
SqlDataReader does not data - does not read data
When I run the SQL statement from SQL Server - a result set is returned.
ID UserName PerLevel
1 US\\nathanm 1
sql string in debug
"select * from PermissionLevel where username = 'US\\nathanm'"
protected int getdata(string username)
int permissionlevel = 0;
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyTestDbConnectionString"].ConnectionString);
string sql = "select * from PermissionLevel where username = '" + username + "'";
SqlCommand sc = new SqlCommand(sql,conn);
sc.CommandType = System.Data.CommandType.Text;
SqlDataReader rdr = sc.ExecuteReader();
permissionlevel = rdr.GetInt16(2);