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
Printable View
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
use dts package ; create a module ; and execute it from vb code
cheers
sakshi
Use something likeQuote:
Originally Posted by asm
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 SubYou 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.Quote:
Originally Posted by asm
DTS if for SQL Server not for Access... :)Quote:
Originally Posted by sakshi
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
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
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.