using System;
using System.Data;
using System.Data.OleDb;
namespace test{
    class Program
    {
        static void Main(string[] args)
        {
            
            OleDbConnection con = new OleDbConnection(); 
            OleDbCommand cmd = new OleDbCommand();
            OleDbDataAdapter dapter = new OleDbDataAdapter();
            String conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= D:\\1.mdb";
            con.ConnectionString = conStr;
            con.Open();
            cmd.Connection = con;
            String SQLStr = "if object_id(N'detectingCannalId') is Null create table detectingCannalId(detectingNo varchar(20) not null,cannalId int not null,checked bit not null default 0 )";
            cmd.CommandText = SQLStr;
            cmd.CommandType = CommandType.Text;
            
            cmd.ExecuteNonQuery();
        }
    }
    }SQLStr = "if object_id(N'detectingCannalId') is Null create table detectingCannalId(detectingNo varchar(20) not null,cannalId int not null,checked bit not null default 0 )";
不可执行
SQLStr = "create table detectingCannalId(detectingNo varchar(20) not null,cannalId int not null,checked bit not null default 0 )";
可执行该如何做给可行代码,拒绝无完整且正确语句的概念介绍。

解决方案 »

  1.   

    object_id这是sqlserver的,不是access的
      

  2.   

    请问楼上有什么SQL语句能对ACCESS执行判断有无表,无表就新建的??
      

  3.   

    Public function tableExists(findTable as string) as boolean  
      Dim rstSchema As New ADODB.Recordset  
      Set rstSchema = cn.OpenSchema(adSchemaTables)  
      rstSchema.Find "TABLE_NAME= '" & findTable &"'"  
      If rstSchema.EOF Then  
      TableExists= False  
      Else  
      TableExists = True  
      End If  
      rstSchema.Close  
    End Function好像大家推荐以上方式处理OLEDB
    这代码对ACCESS,SQLSERVER,ORACEL都能用么??
      

  4.   

    http://wenku.baidu.com/view/8c75bcddd15abe23482f4dff.html#