I have answer to your problem.
Your query does not return any row.. this means your reader has now rows. so how you can write
(if dr.read()) <br />
{<br />
..<br />
..<br />
}
use this
<br />
SqlCommand cmd = new SqlCommand();<br />
SqlDataReader rdr = null;<br />
conn.Open();<br />
String str = "select name from Company where CCode='12345'";<br />
cmd.CommandText = str;<br />
cmd.Connection = conn;<br />
rdr = cmd.ExecuteReader();<br />
if (rdr.HasRows)<br />
{<br />
while (rdr.read())<br />
{System.Windows.MessageBox.Show("Test");<br />
<br />
this.txtname.Text = rdr["column name"];<br />
}<br />
<br />
}<br />
I think this will definitely help you
if yes plz reply me..
inder2305@gmail.com