CreateQueryDef and Execute

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew

    CreateQueryDef and Execute

    Hi:

    I run into the following problem where I would use CreateQuerydef to create
    a new Table and then use "Execute" to execute the statement. However, I
    keep getting an error message saying that the table already exists! (Error
    3010 Table already exists). But I made sure that the table were dropped
    before I executed the statement and I went into the database to check that
    the table was deleted before I ran the "execute" statement. Here are my
    codes:

    On Error Resume Next
    sSql = "Drop Table " & sTableName
    conData.Execute sSql

    Set qdf = conData.CreateQ ueryDef("", _
    "CREATE TABLE " & sTableName & " (DelimitedField s TEXT 255))")
    qdf.Execute


    Can somebody please tell me why I keep getting the error message ( Error
    3010 Table already exists )?



  • Mike Preston

    #2
    Re: CreateQueryDef and Execute

    On Tue, 17 Aug 2004 14:52:00 -0400, "Andrew" <andrew@abc.c a> wrote:
    [color=blue]
    >Hi:
    >
    >I run into the following problem where I would use CreateQuerydef to create
    >a new Table and then use "Execute" to execute the statement. However, I
    >keep getting an error message saying that the table already exists! (Error
    >3010 Table already exists). But I made sure that the table were dropped
    >before I executed the statement and I went into the database to check that
    >the table was deleted before I ran the "execute" statement. Here are my
    >codes:
    >
    > On Error Resume Next
    > sSql = "Drop Table " & sTableName
    > conData.Execute sSql
    >
    > Set qdf = conData.CreateQ ueryDef("", _
    > "CREATE TABLE " & sTableName & " (DelimitedField s TEXT 255))")
    > qdf.Execute
    >
    >
    >Can somebody please tell me why I keep getting the error message ( Error
    >3010 Table already exists )?[/color]

    Probably not. But you can probably figure it out yourself by dropping
    the line:
    [color=blue]
    > On Error Resume Next[/color]

    from the above.

    mike

    Comment

    • david epsom dot com dot au

      #3
      Re: CreateQueryDef and Execute

      conData.Tablede fs.Refresh

      (david)

      "Mike Preston" <mbpatpas.inval id@pacbell.net> wrote in message
      news:4122636c.6 01701450@news.I NDIVIDUAL.NET.. .[color=blue]
      > On Tue, 17 Aug 2004 14:52:00 -0400, "Andrew" <andrew@abc.c a> wrote:
      >[color=green]
      > >Hi:
      > >
      > >I run into the following problem where I would use CreateQuerydef to[/color][/color]
      create[color=blue][color=green]
      > >a new Table and then use "Execute" to execute the statement. However, I
      > >keep getting an error message saying that the table already exists![/color][/color]
      (Error[color=blue][color=green]
      > >3010 Table already exists). But I made sure that the table were dropped
      > >before I executed the statement and I went into the database to check[/color][/color]
      that[color=blue][color=green]
      > >the table was deleted before I ran the "execute" statement. Here are my
      > >codes:
      > >
      > > On Error Resume Next
      > > sSql = "Drop Table " & sTableName
      > > conData.Execute sSql
      > >
      > > Set qdf = conData.CreateQ ueryDef("", _
      > > "CREATE TABLE " & sTableName & " (DelimitedField s TEXT[/color][/color]
      255))")[color=blue][color=green]
      > > qdf.Execute
      > >
      > >
      > >Can somebody please tell me why I keep getting the error message ( Error
      > >3010 Table already exists )?[/color]
      >
      > Probably not. But you can probably figure it out yourself by dropping
      > the line:
      >[color=green]
      > > On Error Resume Next[/color]
      >
      > from the above.
      >
      > mike[/color]


      Comment

      • Pieter Linden

        #4
        Re: CreateQueryDef and Execute

        total shot in the dark, but did you try refreshing the tabledefs
        collection after the delete?

        Comment

        • Andrew

          #5
          Re: CreateQueryDef and Execute

          Hi:

          Thanks for replying. I figured out it didn't work. It was my mistake!! I
          incorrectly placed the Create Table statement within a For - Loop.
          Obviously, the first time around the loop, the table was successfully
          created. The second time around the loop, the table is already there and
          hence the "Error Message".





          "Pieter Linden" <pietlinden@hot mail.com> wrote in message
          news:bf31e41b.0 408172023.f7abc bb@posting.goog le.com...[color=blue]
          > total shot in the dark, but did you try refreshing the tabledefs
          > collection after the delete?[/color]


          Comment

          • Andrew

            #6
            Re: CreateQueryDef and Execute

            Hi:

            Thanks for replying. I figured out it didn't work. It was my mistake!! I
            incorrectly placed the Create Table statement within a For - Loop.
            Obviously, the first time around the loop, the table was successfully
            created. The second time around the loop, the table is already there and
            hence the "Error Message".


            "Mike Preston" <mbpatpas.inval id@pacbell.net> wrote in message
            news:4122636c.6 01701450@news.I NDIVIDUAL.NET.. .[color=blue]
            > On Tue, 17 Aug 2004 14:52:00 -0400, "Andrew" <andrew@abc.c a> wrote:
            >[color=green]
            > >Hi:
            > >
            > >I run into the following problem where I would use CreateQuerydef to[/color][/color]
            create[color=blue][color=green]
            > >a new Table and then use "Execute" to execute the statement. However, I
            > >keep getting an error message saying that the table already exists![/color][/color]
            (Error[color=blue][color=green]
            > >3010 Table already exists). But I made sure that the table were dropped
            > >before I executed the statement and I went into the database to check[/color][/color]
            that[color=blue][color=green]
            > >the table was deleted before I ran the "execute" statement. Here are my
            > >codes:
            > >
            > > On Error Resume Next
            > > sSql = "Drop Table " & sTableName
            > > conData.Execute sSql
            > >
            > > Set qdf = conData.CreateQ ueryDef("", _
            > > "CREATE TABLE " & sTableName & " (DelimitedField s TEXT[/color][/color]
            255))")[color=blue][color=green]
            > > qdf.Execute
            > >
            > >
            > >Can somebody please tell me why I keep getting the error message ( Error
            > >3010 Table already exists )?[/color]
            >
            > Probably not. But you can probably figure it out yourself by dropping
            > the line:
            >[color=green]
            > > On Error Resume Next[/color]
            >
            > from the above.
            >
            > mike[/color]


            Comment

            Working...