ahmed saleh

ahmed saleh

  • NA
  • 9
  • 6.4k

the read() method doesn,t work with multiple tables in sql d

Jan 7 2014 7:19 PM

hi guys

I'm trying to access 2 tables from sql in c#

when I tried

this

string mycommand = " select * from mytable1";

sqlcommand com = new sqlcommand();
com.comandtext = mycommand;

sqldatareader reader = com.excutereader();

while(reader.read()){
...
.....
}

he enters the loop and the command is work

but..

when i try doing this with 2 tables like this

string mycommand = " select  mytable1.name,maytable2.city from maytable1 INNER JOIN mytable2 ON mytable1.cityid = mytable2.cityid ";

..

....

.... every thing is good until now


while(reader.read()){  /here is the problem the code doesn,t enter the loop at all !!

..

...

}

he just ignore this read() method and continue the code without entering the loop,and iam sure from that

because i put the break point ..

so i hope you guys can help me in this problem

thank you


Answers (1)