Executereader requires an open and available connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manesh Pawar
    New Member
    • Sep 2010
    • 15

    Executereader requires an open and available connection

    Hello,
    I m getting an error "System.Invalid OperationExcept ion - Executereader requires an open and available connection"
    I have Open an Connection, but still it throughs an Error. But it occurs Sometimes..

    Following is the code,
    Code:
     
    
     if (con == null)
         con = new OleDbConnection("" + StrConnection);
     
     if (con.State == ConnectionState.Closed)
         con.Open();
       OleDbCommand cmd = new OleDbCommand("Select (Max(BOMId)+1) as BOMNo from BOM ", con);
      [B][B][I]OleDbDataReader dr = cmd.ExecuteReader();[/I][/B] [/B][B][I]// error occurs at this Line  [/I][/B]
         while (dr.Read())
           {
              ----

    What Could be the problem??
Working...