Get value from field - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Get value from field

marcobranco75marcobranco75 Posts: 1Member
Hi i need to get the value of a field:

How could i get the value of the field request (the field type is boolean

Thank's in advance

Here is the code:
[code]string sql = "SELECT request FROM Table1 where id = 10";
string connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
cmd.CommandText = sql;
SqlDataReader dr;
dr = cmd.ExecuteReader();[/code]

Thank's in advance

Comments

  • mnagaria2011mnagaria2011 Posts: 2Member
    Hi,

    I believe you can do something like below. The syntax might not be correct but you will get an idea.

    while (reader.Read())
    {
    if(reader.GetValue(0) != DBNull.Value)
    {
    bool result = reader.GetValue(0)
    }

    }

    Hope this helps
    ASP.NET Hosting
Sign In or Register to comment.