CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010
    Posts
    22

    HELP: Why EXcute() of CDaodatabase does not work with "CREATE TABLE" sql

    Using CDaodatabase and CDaoRecordset to work with Sql2000 personal.

    sql = _T("SELECT * INTO YOU FROM MY WHERE 1=2");
    db.Execute(sql);

    Excute() is doing well with copying a table, but

    sql = _T("CREATE TABLE THEY (DATES Long NOT NULL PRIMARY KEY,CROSS Long NULL);");
    db.Execute(sql);

    Excute( ) does not work!!! it does not work with "CREATE TABLE" sql!!!!

    Why??
    Last edited by genliu777; November 16th, 2011 at 08:52 PM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: HELP: Why EXcute() of CDaodatabase does not work with "CREATE TABLE" sql

    Quote Originally Posted by genliu777 View Post
    Using CDaodatabase and CDaoRecordset to work with Sql2000 personal.
    Code:
    	sql = _T("SELECT * INTO YOU FROM MY WHERE 1=2");
    	db.Execute(sql);
    Excute() is doing well with copying a table, but
    How can it copy anything with such a condition: "WHERE 1=2"?

    Quote Originally Posted by genliu777 View Post
    Code:
            sql = _T("CREATE TABLE THEY (DATES Long NOT NULL PRIMARY KEY,CROSS Long NULL);");
    	db.Execute(sql);
    Excute( ) does not work!!! it does not work with "CREATE TABLE" sql!!!!

    Why??
    Define "does not work". What error do you get?
    Besides, i don't see any exception handling in your code snippet. Don't you use it?
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2010
    Posts
    22

    Re: HELP: Why EXcute() of CDaodatabase does not work with "CREATE TABLE" sql

    "WHERE 1=2" means copying table structure without any data or record! it works well with ACCESS.


    "does not work" according to the create sql words, it should create a table in the database! but no new table is created.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: HELP: Why EXcute() of CDaodatabase does not work with "CREATE TABLE" sql

    Quote Originally Posted by genliu777 View Post
    "WHERE 1=2" means copying table structure without any data or record! it works well with ACCESS.
    Ok, now it is clear.

    Quote Originally Posted by genliu777 View Post
    "does not work" according to the create sql words, it should create a table in the database! but no new table is created.
    Well, then again:
    Quote Originally Posted by VictorN View Post
    ...
    Besides, i don't see any exception handling in your code snippet. Don't you use it?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured