How can I write a true SELECT statement?(for accsesing and using a data in database)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maryam raj
    New Member
    • Jan 2011
    • 1

    How can I write a true SELECT statement?(for accsesing and using a data in database)

    Code:
     
    
    
    SqlConnection dbCon = new SqlConnectio(connectionstring);
    SqlCommand sqlCom = new SqlCommand();
    sqlCom.CommandText = "SELECT FROM rizha";//comment:rizha is a table
         try
        {
        SqlDataReader dr;
        dbCon.Open();
        dr = sqlCom.ExecuteReader();
        if (dr.HasRows == true )
        {//comment:I run with break piont and I undrestand this line never run in debuging and i dont know why?
                      
            textBox7.Text  = (String)dr["tnine"];
        }//comment:"tnine" is a record
            dr.Close();
            dbCon.Close();
                
        while (dr.Read())
        {
    textBox7.Text=textBox7.Text+ (dr["tnine"]).ToString();
    //comment:use textBox to access data    
     } 
         
    }
    catch (Exception ex)
     { } 
    
      }
  • Christian Binder
    Recognized Expert New Member
    • Jan 2008
    • 218

    #2
    You missed a *
    SELECT * FROM rizha

    Comment

    Working...