Results 1 to 2 of 2

Thread: Copying MS Access Table with code

  1. #1

    Thread Starter
    Member Shadow45o's Avatar
    Join Date
    Sep 2008
    Posts
    51

    Question Copying MS Access Table with code

    Ok...I have done a fair amount of searching...no luck...Originally I was trying to create a new table and change the input mask with code, no such luck.

    Now I am trying to copy the MS access table(hoping to keep the input mask). I have the table copying and renaming, but it fails to keep the input mask...

    So far this copies and clears the table, is there anything I am missing to make it keep the input mask

    The code below is what I am using:

    vb Code:
    1. Query = "SELECT * INTO [test] FROM [tblAccounts] WHERE 1=2"
    2.         comm = New OleDbCommand(Query, conn)
    3.  
    4.         Try
    5.             conn.Open()
    6.             comm.ExecuteNonQuery()
    7.         Catch ex As OleDb.OleDbException
    8.         Catch ex As Exception
    9.             MsgBox(ex.Message & vbCrLf & ex.StackTrace)
    10.         Finally
    11.             If Not (conn Is Nothing) Then
    12.                 comm.Dispose()
    13.                 comm = Nothing
    14.             End If
    15.         End Try

    Thanks for any help

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Copying MS Access Table with code

    If they have Access installed then you can use the Access Object Model and execute the .TransferDatabase funciton.

    This is VBA code but is easy to do in .NET
    http://www.vbforums.com/showthread.php?t=409309
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Tags for this Thread

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