drop Microsoft Access XP table with Visual Basic

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • delete table with Visual Basic 6

    drop Microsoft Access XP table with Visual Basic

    Dear developer,
    I have an error message when I try to delete or drop Microsoft Access XP
    table with ADOX in Visual Basic 6. I use the ADOX.Catalog and ADOX.table to
    create and delete or drop table within Visual Basic program.
    If anybody knows how to solve the problem, please give me the solution.
    I would like to thank you for your attention and response.

    Best regard,

    Sanad
  • Leon Mayne [MVP]

    #2
    Re: drop Microsoft Access XP table with Visual Basic

    delete table with Visual Basic 6 wrote:[color=blue]
    > Dear developer,
    > I have an error message when I try to delete or drop Microsoft Access
    > XP table with ADOX in Visual Basic 6. I use the ADOX.Catalog and
    > ADOX.table to create and delete or drop table within Visual Basic
    > program.
    > If anybody knows how to solve the problem, please give me the
    > solution.
    > I would like to thank you for your attention and response.[/color]

    Hello,
    What's the error message you're getting?


    Comment

    • Miha Markic [MVP C#]

      #3
      Re: drop Microsoft Access XP table with Visual Basic

      Hi,

      This is a wrong newsgroup for vb 6 (this is *dotnet*).
      Anyway, what error do you get?
      Maybe the table in question is referenced by another table and thus can't be
      dropped?

      --
      Miha Markic [MVP C#] - RightHand .NET consulting & development
      SLODUG - Slovene Developer Users Group


      "delete table with Visual Basic 6" <delete table with Visual Basic
      6@discussions.m icrosoft.com> wrote in message
      news:E4B9C5C0-FB74-4080-A1B4-7576920DF0AF@mi crosoft.com...[color=blue]
      > Dear developer,
      > I have an error message when I try to delete or drop Microsoft Access XP
      > table with ADOX in Visual Basic 6. I use the ADOX.Catalog and ADOX.table
      > to
      > create and delete or drop table within Visual Basic program.
      > If anybody knows how to solve the problem, please give me the solution.
      > I would like to thank you for your attention and response.
      >
      > Best regard,
      >
      > Sanad[/color]


      Comment

      • delete table with Visual Basic 6

        #4
        Re: drop Microsoft Access XP table with Visual Basic

        My error message is "Run time error '3265': Item cannot be found in the
        collectioin corresponding to the requested name or ordinal". But when I check
        my database, the table to be deleted is exist. And also the name is excactly
        the same with the value of the variable DelCodeNumber.
        Here is the code:
        Dim catStok As New ADOX.Catalog
        Dim tblStok As New ADOX.Table

        catStok.ActiveC onnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" &
        "Data Source=C:\dbSto k.mdb;"
        tblStok.Name = DelCodeNumber
        catStok.Tables. Delete tblStok
        Set catStok.ActiveC onnection = Nothing
        Set catStok = Nothing

        Thank you very much for your attention

        Best Regard,

        Sanad
        "Leon Mayne [MVP]" wrote:
        [color=blue]
        > Hello,
        > What's the error message you're getting?[/color]

        Comment

        • Leon Mayne [MVP]

          #5
          Re: drop Microsoft Access XP table with Visual Basic

          delete table with Visual Basic 6 wrote:[color=blue]
          > Dim catStok As New ADOX.Catalog
          > Dim tblStok As New ADOX.Table
          >
          > catStok.ActiveC onnection =
          > "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Data Source=C:\dbSto k.mdb;"
          > tblStok.Name = DelCodeNumber
          > catStok.Tables. Delete tblStok
          > Set catStok.ActiveC onnection = Nothing
          > Set catStok = Nothing[/color]

          Have you stepped through to check the value of DelCodeNumber to make sure
          it's correct?


          Comment

          • delete table with Visual Basic 6

            #6
            Re: drop Microsoft Access XP table with Visual Basic

            I have stepped through to check the value of DelCodeNumber, and the value I
            use is "1", because indeed the table name I create in the database is a kind
            of code number, like "1" , "12" , "25", "314", etc.
            So the value of variable DelCodeNumber is "1", not "1.tbl". I had use the
            "1.tbl" but the result is the same.

            catStok.ActiveC onnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" &
            "Data Source=C:\dbSto k.mdb;"
            tblStok.Name = NoKodeDel + ".tbl"

            catStok.Tables. Delete tblStok --> Here the program stop running

            Set catStok.ActiveC onnection = Nothing
            Set catStok = Nothing

            I use Visual Basic 6 within Visual Studio 6 Enterprise Edition, and Ms
            Access XP.
            If you have a better or another way just to delete / drop Ms Access XP table
            with Visual Basic 6, let me know. Or may be have I to use Ms Access 97 and
            use DAO ?

            Thank you very much for your attention.

            "Leon Mayne [MVP]" wrote:
            [color=blue]
            > Have you stepped through to check the value of DelCodeNumber to make sure
            > it's correct?
            >
            >
            >[/color]

            Comment

            • delete table with Visual Basic 6

              #7
              RE: drop Microsoft Access XP table with Visual Basic

              Finally, I get the answer!!!
              I get the answer in the Visual Basic-database.ado section in this newsgroup
              date 4/1/2005 by Brendan Reynolds.
              Thank you again for Mr.Brendan Reynolds.

              The answer is:

              "If the function returns True, call Catalog.Tables. Delete YOURTABLENAME to
              delete the table."

              My mistake is

              Dim tblStok As New ADOX.Table

              tblStok.Name = DelCodeNumber
              Catalog.Tables. Delete tblStok --> error

              Catalog.Tables. Delete DelCodeNumber --> correct

              By the way, I appreciate Mr. Leon Mayne for the VERY FAST attention and
              answer. And also thank you for Mr.Miha Markic for the advice and forgiveness.

              All right, have a nice work. Your work means a lot for us.

              Best regard,

              Sanad


              Comment

              • Leon Mayne [MVP]

                #8
                Re: drop Microsoft Access XP table with Visual Basic

                delete table with Visual Basic 6 wrote:[color=blue]
                > Finally, I get the answer!!![/color]

                Glad you found the answer. Sorry I couldn't help earlier.


                Comment

                • Paul Clement

                  #9
                  Re: drop Microsoft Access XP table with Visual Basic

                  On Mon, 10 Jan 2005 02:15:04 -0800, "delete table with Visual Basic 6" <delete table with Visual
                  Basic 6@discussions.m icrosoft.com> wrote:

                  ¤ Dear developer,
                  ¤ I have an error message when I try to delete or drop Microsoft Access XP
                  ¤ table with ADOX in Visual Basic 6. I use the ADOX.Catalog and ADOX.table to
                  ¤ create and delete or drop table within Visual Basic program.
                  ¤ If anybody knows how to solve the problem, please give me the solution.
                  ¤ I would like to thank you for your attention and response.
                  ¤

                  BTW, you can also use Access SQL DDL:

                  DROP TABLE TableName


                  Paul ~~~ pclement@amerit ech.net
                  Microsoft MVP (Visual Basic)

                  Comment

                  Working...