开发者

how to get exact record using datareader

Can you please correct this code so that i can get particular companyName corresponding to the seekerID when i开发者_C百科 select the particular seekerID ... Pls its urgent.

while (reader.Read()) { if (lblseekerID.Text != Request.QueryString["seekerID"]) { //if it is a text box txtAdminCompany.Text = "wrong";

               }
               else
              {
                  //txtAdminCompany.Text = reader.["companyName"].ToString();
                   txtAdminCompany.Text=reader.IsDBNull(reader.GetOrdinal("companyName"))? null: reader["companyName"].ToString();
               }
          }


Just use

reader["companyName"]

instead.

Also, without seeing the db query that precedes your code, I suspect your SQL query may be the root of the problem. You should be doing something like:

cmd.CommandText = "SELECT * FROM myTable WHERE seekerID = " + seekID.ToString(); // cmd = SqlCommand object

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜