dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: IF statement problems c#

  1. #1
    Join Date
    Nov 2003
    Posts
    20

    IF statement problems c#

    Hi All,

    I new to C# and i have been having problems which an if statement. I have a ASP.NET page which uses an IF statement to check against database results. Here is the code:

    <%@Import Namespace="System.Data.OleDb"%>

    <Script Language="C#" Runat=Server>
    void Page_Load(){
    OleDbConnection objConn = new OleDbConnection(
    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Inetpub\\database.mdb");
    OleDbCommand objCmd = new OleDbCommand("Select Available FROM Paused WHERE ID=1;", objConn);

    objConn.Open();
    OleDbDataReader objRdr = objCmd.ExecuteReader();
    while (objRdr.Read()){

    if(objRdr["Available"]=="True"){
    Response.Write("iResult = 1");
    }else{
    Response.Write("iResult = 0");
    }

    }
    objRdr.Close();
    objConn.Close();
    }
    </Script>

    Each time the code runs it output's 'iResult = 0' even though the database field is 'True'.

    Any suggestions appreciated.

    Thanks

  2. #2
    Join Date
    Nov 2003
    Posts
    655
    I believe Access actually uses -1 for Yes and 0 for No if you're using the Yes/No data type.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles