You can use the SQLMAINT utility that ships with SQL 7.0 and call it from a VB
program using the ADO command object.
Here is a sample.
Dim objCnn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim strQuery As String
strQuery = "exec master..xp_cmdshell " & "'" & "sqlmaint -S <server> -U
""<user>"" -P "<password>" -D <database-name> -BkUpDB -BkUpMedia DISK
-UseDefDir" & "'" ', no_output" & "'"
objCnn.Open "Provider=sqloledb.1;data source=macs;user id=sa;password=;"
objCmd.ActiveConnection = objCnn
objCmd.CommandType = adCmdText
objCmd.CommandText = strQuery
Substitute your server, user id, password and database name in the string
strQuery. This code will back up your
database in the folder defined as the default for your sql server backups.
> From my VB6.0 application i would like to backup the Sql Server database. I
> cannot do direct copy, because it would say access is denied. Can anybody
> tell me of how to do it.
> Thanks in advance