请问下列语句错在哪里?怎样才是正确的?谢了adoquery1.sql.add('create index zzz on baocan(xm,rq)');         //运行出错
adoquery1.execsql;
 
adoquery1.sql.add('drop table baocan');
adoquery1.execsql;以上命令在SQL查询器里运行正常,但是在delphi里就报错,是不是SQL命令只有少数几个命令(如:select ,update,delete)才能在SQL里运行呢?其它的命令要通过过程存储才能实现?

解决方案 »

  1.   

    在DELPHI中大家一般都是使用ADO组件,当然需要你构造一个SQL语句。 
    第一个IF返回的结果用来控制代码的下一步的流程。。 
    轉換成delphi語句:if   exists(select   1   from   sysobjects   where   xtype   =   'U '   and   id   =   Object_id(N 'tablename ')) 
    then   drop   table   tablename; 
    else 
        create   table   tablename(); 
      

  2.   

    先连接好数据库
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('create table 表名( 学号 char(20),姓名 char(20),班级 char(20))');
    adoquery1.execsql;
      

  3.   

    楼上是哪里的人,SQL的写法我们以前的一个同志很像,不过好像是错了。
      

  4.   

    保证数据库连接,清除sql。关闭数据源,赋予sql,打开·执行
      

  5.   

    先连接好数据库,就是设置adoconnection的属性。。
      

  6.   

    删除表?
    试试:
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add(drop table table_name'); 
    adoquery1.execsql;