日期:2014-05-18  浏览次数:20952 次

新手:c#中oledb提交SQL语句问题请指点
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 )";
可执行

该如何做给可行代码,拒绝无完整且正确语句的概念介绍。

------解决方案--------------------
object_id这是sqlserver的,不是access的