Results 1 to 7 of 7

Thread: access200 database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    access200 database

    Hi

    How can I print the structure of table in access2000.
    How can I backup access2000 database through vb6 coding.

    Please help how to do this.


    thanks


    asm

  2. #2
    New Member
    Join Date
    Jun 2005
    Posts
    8

    Re: access200 database

    use dts package ; create a module ; and execute it from vb code
    cheers
    sakshi

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: access200 database

    Quote Originally Posted by asm
    Hi

    How can I print the structure of table in access2000.
    Use something like
    VB Code:
    1. Private Sub GetFieldNames(Rs As Recordset)
    2.    
    3.     Dim i As Integer ' looper variable
    4.     Dim iFieldsCount As Integer
    5.     iFieldsCount = Rs.Fields.Count
    6.     For i = 0 To iFieldsCount - 1
    7.         'loop through each field name and add it to listbox
    8.         lstFields.AddItem Rs.Fields(i).Name
    9.    Next i
    10.  
    11. End Sub
    Quote Originally Posted by asm
    How can I backup access2000 database through vb6 coding.
    You can use VB's FileCopy to copy your database to a backup folder. NOTE: Your database MUST be closed in order for this function properly.

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: access200 database

    Quote Originally Posted by sakshi
    use dts package ; create a module ; and execute it from vb code
    cheers
    sakshi
    DTS if for SQL Server not for Access...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: access200 database

    Aside from FileCopy as Hack suggested you could also use the FileSystemObject which could copy an Access database even if it's open...

    VB Code:
    1. Public Sub BkUpDB()
    2.     'Reference Microsoft Scripting Runtime
    3.     Dim fsoObject As FileSystemObject
    4.     Set fsoObject = New FileSystemObject
    5.     'DBPath is a variable where your access database is located
    6.     'DBBkUpPath is where you want to copy the database
    7.     fsoObject.CopyFile DBPath, DBBkUpPath, True
    8.     Set fsoObject = Nothing
    9. End Sub
    Last edited by dee-u; Oct 9th, 2008 at 12:24 PM.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    Addicted Member
    Join Date
    Dec 2005
    Posts
    163

    Re: access200 database

    here's another for ya...

    VB Code:
    1. Public Sub EncodeFile(SourceFile As String, DestFile As String)
    2. On Error GoTo errh
    3.   Dim ByteArray() As Byte
    4.   Dim Filenr As Integer
    5.  
    6.   'Make sure the source file exists
    7.   If (Not FileExist(SourceFile)) Then
    8.     Err.Raise vbObjectError, "EncodeFile()", "Source file does not exist"
    9.   End If
    10.  
    11.   'Read the data from the sourcefile
    12.   Filenr = FreeFile
    13.   Open SourceFile For Binary As #Filenr
    14.   ReDim ByteArray(0 To LOF(Filenr) - 1)
    15.   Get #Filenr, , ByteArray()
    16.   Close #Filenr
    17.  
    18.   'Compress the data
    19.   Call EncodeByte(ByteArray(), UBound(ByteArray) + 1)
    20.  
    21.   'If the destination file exist we need to
    22.   'destroy it because opening it as binary
    23.   'will not clear the old data
    24.   If (FileExist(DestFile)) Then Kill DestFile
    25.  
    26.   'Save the destination string
    27.   Open DestFile For Binary As #Filenr
    28.   Put #Filenr, , ByteArray()
    29.   Close #Filenr
    30.   Call MsgBox("Your database is now Backed up and saved." & vbCrLf & "Remember to Back your database everyday", vbInformation)
    31.  
    32. Exit Sub
    33.  
    34. errh:
    35. If Err.Number = 71 Then
    36. Call MsgBox("There is no discette in drive A:" & vbCrLf & "Please insert a disk to backup your data" & vbCrLf & Err.Description, vbExclamation)
    37. Else
    38. MsgBox Err.Number & vbCrLf & Err.Description
    39. End If
    40. End Sub

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: access200 database

    FileExists generates an error, and your Encode() routine is missing. Other than that, it's good code. I got it to run, but would like to see the encrypt/decrypt module. It could be useful to compress it.
    Last edited by dglienna; Dec 12th, 2005 at 11:23 PM.

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