问题:
   在vc#环境下,一个select语句对一个表tab1进行操作,返回一个bool值(或者返回一个int值),怎么实现?着急!!!!!1!
   参考代码(请修改)如下:
   OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
  aConnection.Open(); 
  OleDbCommand aCommand = new OleDbCommand("select tel from  telnumber where tel = 'strn3' ", aConnection);
  
  int nn = aCommand.ExecuteNonQuery();
  if (nn==0)
  {

   }

解决方案 »

  1.   

    try{
    OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
      aConnection.Open(); 
      OleDbCommand aCommand = new OleDbCommand("select tel from  telnumber where tel = 'strn3' ", aConnection);
      aConnection.open();
      int nn = Convert.toint32(aCommand.ExecuteNonQuery());
      aConnection.close();
      if (nn>0)
      {
           return true;
      }
    else
          return false;
    catch
    {
        return false;
    }