|
-
Dec 12th, 2005, 06:21 AM
#1
Thread Starter
Hyperactive Member
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
-
Dec 12th, 2005, 07:03 AM
#2
New Member
Re: access200 database
use dts package ; create a module ; and execute it from vb code
cheers
sakshi
-
Dec 12th, 2005, 07:04 AM
#3
Re: access200 database
 Originally Posted by asm
Hi
How can I print the structure of table in access2000.
Use something like
VB Code:
Private Sub GetFieldNames(Rs As Recordset)
Dim i As Integer ' looper variable
Dim iFieldsCount As Integer
iFieldsCount = Rs.Fields.Count
For i = 0 To iFieldsCount - 1
'loop through each field name and add it to listbox
lstFields.AddItem Rs.Fields(i).Name
Next i
End Sub
 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.
-
Dec 12th, 2005, 08:06 PM
#4
Re: access200 database
 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...
-
Dec 12th, 2005, 08:09 PM
#5
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:
Public Sub BkUpDB()
'Reference Microsoft Scripting Runtime
Dim fsoObject As FileSystemObject
Set fsoObject = New FileSystemObject
'DBPath is a variable where your access database is located
'DBBkUpPath is where you want to copy the database
fsoObject.CopyFile DBPath, DBBkUpPath, True
Set fsoObject = Nothing
End Sub
Last edited by dee-u; Oct 9th, 2008 at 12:24 PM.
-
Dec 12th, 2005, 10:56 PM
#6
Addicted Member
Re: access200 database
here's another for ya...
VB Code:
Public Sub EncodeFile(SourceFile As String, DestFile As String)
On Error GoTo errh
Dim ByteArray() As Byte
Dim Filenr As Integer
'Make sure the source file exists
If (Not FileExist(SourceFile)) Then
Err.Raise vbObjectError, "EncodeFile()", "Source file does not exist"
End If
'Read the data from the sourcefile
Filenr = FreeFile
Open SourceFile For Binary As #Filenr
ReDim ByteArray(0 To LOF(Filenr) - 1)
Get #Filenr, , ByteArray()
Close #Filenr
'Compress the data
Call EncodeByte(ByteArray(), UBound(ByteArray) + 1)
'If the destination file exist we need to
'destroy it because opening it as binary
'will not clear the old data
If (FileExist(DestFile)) Then Kill DestFile
'Save the destination string
Open DestFile For Binary As #Filenr
Put #Filenr, , ByteArray()
Close #Filenr
Call MsgBox("Your database is now Backed up and saved." & vbCrLf & "Remember to Back your database everyday", vbInformation)
Exit Sub
errh:
If Err.Number = 71 Then
Call MsgBox("There is no discette in drive A:" & vbCrLf & "Please insert a disk to backup your data" & vbCrLf & Err.Description, vbExclamation)
Else
MsgBox Err.Number & vbCrLf & Err.Description
End If
End Sub
-
Dec 12th, 2005, 11:03 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|