放到try语句中,如果没有会弹出异常,在catch中处理

解决方案 »

  1.   

    现在问题是这样,我的这些个表名全部存放在一个文件里面,如果其中的一个表名是错误的,那我这样:
      try 
      {
        select * from table1;
    }
     catch(Exception e)
    {
       this.close();
    }
    这样我就不能接着处理下面的正确的表了,我就是想跳过它,不知道各位大哥有没有好的办法
    多谢了
      

  2.   

    如果你的数据库是SQL SERVER,则SQL语句为:if exists( select 1 from sysobjects where name='你的表名' and xtype='U')
      

  3.   

    如果是 SqlServer的库
    select * from dbo.sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    如果有结果返回测表存在
      

  4.   

    OleDbConnection.GetOleDbSchemaTable可以获取数据库中的所有表的信息
      

  5.   

    to hhzh426(春之风)
     Sqlconnection中没有这个方法啊
      

  6.   

    如果是sqlconnection(只能与sql server相连),你可以通过查找系统表的方法来找到。
    select name from sysobjects where name='tablename'
    sqlcommand.execnoquery()
      

  7.   

    select * from sysobjects where name='你的表名' and xtype='U'
    选出该表在系统中的记录,没有记录数为0