Groups > Databases > MySQL for ASP.NET > Not Reading when using odbcDataReader




Not Reading when using odbcDataReader

Not Reading when using odbcDataReader
Sun, 16 Mar 2008 18:35:04 +000
Hi i am using the following code

 

1            ArrayList userList = new ArrayList();
2            OdbcConnection userCon = dataCon.connect();
3            userCon.Open();
4            OdbcCommand userCom = new OdbcCommand("SELECT
tbl_usr.local_id,tbl_usr.decode_id,tbl_privs.priv_lvl FROM tbl_usr INNER JOIN
tbl_privs ON tbl_usr.priv_id=tbl_privs.priv_id WHERE priv_lvl >= '1'",
userCon);
5            OdbcDataReader userRead = userCom.ExecuteReader();
6    while (userRead.Read())
7            {
8                userList.Add(new
user(userRead["local_id"].ToString(),
userRead["decode_id"].ToString(),
Convert.ToInt32(userRead["priv_lvl"].ToString())));
9            }
10           userRead.Close();
11           userCon.Close();
12           listOfUsers = (user[])userList.ToArray(typeof(user));


  Now i know the code itself works fine the problem is with the Odbccommand sql

if i change the sql command to this:

 

SELECT tbl_usr.local_id,tbl_usr.decode_id,tbl_privs.priv_lvl FROM tbl_usr INNER
JOIN tbl_privs ON tbl_usr.priv_id=tbl_privs.priv_id

If works fine and will do the .read set of code

if i leave it as 

SELECT tbl_usr.local_id,tbl_usr.decode_id,tbl_privs.priv_lvl FROM tbl_usr INNER
JOIN tbl_privs ON tbl_usr.priv_id=tbl_privs.priv_id WHERE priv_lvl >= '1'

or 

SELECT tbl_usr.local_id,tbl_usr.decode_id,tbl_privs.priv_lvl FROM tbl_usr INNER
JOIN tbl_privs ON tbl_usr.priv_id=tbl_privs.priv_id WHERE tbl_privs.priv_lvl
>= '1'

It doesnt work and cant find any results but when i run the sql through mysql
querry browser it works fine.

 

Any one got any ideas

 

Thanks

Dan
Post Reply
about | contact