Click here to Skip to main content
15,907,687 members
Home / Discussions / Database
   

Database

 
AnswerRe: Syntax for update statement Pin
Eric Dahlvang3-Aug-06 11:38
Eric Dahlvang3-Aug-06 11:38 
QuestionHow to seperate Date and Time in SQL Pin
ChennaiBabu3-Aug-06 2:06
ChennaiBabu3-Aug-06 2:06 
AnswerRe: How to seperate Date and Time in SQL Pin
WillemM3-Aug-06 3:34
WillemM3-Aug-06 3:34 
AnswerRe: How to seperate Date and Time in SQL Pin
albCode3-Aug-06 5:20
albCode3-Aug-06 5:20 
GeneralRe: How to seperate Date and Time in SQL Pin
Jayamaruthia3-Aug-06 19:46
Jayamaruthia3-Aug-06 19:46 
GeneralRe: How to seperate Date and Time in SQL Pin
albCode3-Aug-06 20:50
albCode3-Aug-06 20:50 
AnswerRe: How to seperate Date and Time in SQL Pin
KeesVer3-Aug-06 10:31
KeesVer3-Aug-06 10:31 
QuestionBACKUP DATABASE command syntax [modified] Pin
Steven J Jowett3-Aug-06 0:53
Steven J Jowett3-Aug-06 0:53 
I am trying to issue a command to MS SQL to perform a backup to a disk file, from a VB.NET 2005 program.

The command structure is as follows :-

BACKUP DATABASE Weighbridge TO DISK = 'C:\SQLBackup\MyServerName\MyDatabaseName_20060803_1108.BAK'

My program reports the following error :-

Incorrect syntax near '\'.

My code is as follows :-

<br />
    Private Sub IssueBackupCommand(ByVal Server As String, ByVal Database As String, ByVal BackupPath As String)<br />
<br />
        Dim sConnectionString As String<br />
        Dim sCommand As String<br />
        Dim sSql As String<br />
<br />
        Dim connection As New System.Data.SqlClient.SqlConnection<br />
        Dim command As New System.Data.SqlClient.SqlCommand<br />
<br />
        Try<br />
            sConnectionString = "Data Source=" & Server & ";Initial Catalog=" & Database & ";Integrated Security=True"<br />
<br />
            sCommand = BackupPath & "\" & Database & "_" & Format(Now(), "yyyyMMdd") & "_" & Format(Now(), "HHMM") & ".BAK"<br />
            sSql = "BACKUP DATABASE " & Database & " TO DISK = '" & sCommand & "'"<br />
<br />
            With connection<br />
                .ConnectionString = sConnectionString<br />
                .Open()<br />
                With command<br />
                    .Connection = connection<br />
                    .CommandType = CommandType.Text<br />
                    .CommandText = sCommand<br />
                    .ExecuteNonQuery() '<--- Error produced here<br />
                End With<br />
                .Close()<br />
            End With<br />
<br />
        Catch ex As System.Exception<br />
            MessageBox.Show(ex.Message)<br />
        Finally<br />
            command.Dispose()<br />
            command = Nothing<br />
            If connection.State <> ConnectionState.Closed Then connection.Close()<br />
            connection.Dispose()<br />
            connection = Nothing<br />
        End Try<br />
<br />
    End Sub


Any help appriciated

Thanks
Steve Jowett


-- modified at 6:53 Thursday 3rd August, 2006
AnswerRe: BACKUP DATABASE command syntax Pin
seea3-Aug-06 0:57
seea3-Aug-06 0:57 
GeneralRe: BACKUP DATABASE command syntax Pin
Steven J Jowett3-Aug-06 1:17
Steven J Jowett3-Aug-06 1:17 
GeneralRe: BACKUP DATABASE command syntax Pin
WillemM3-Aug-06 3:36
WillemM3-Aug-06 3:36 
GeneralRe: BACKUP DATABASE command syntax Pin
Steven J Jowett3-Aug-06 4:12
Steven J Jowett3-Aug-06 4:12 
AnswerRe: BACKUP DATABASE command syntax Pin
Steven J Jowett3-Aug-06 4:34
Steven J Jowett3-Aug-06 4:34 
GeneralRe: BACKUP DATABASE command syntax Pin
WillemM4-Aug-06 4:17
WillemM4-Aug-06 4:17 
QuestionDistinct records problem Pin
psamy3-Aug-06 0:22
psamy3-Aug-06 0:22 
AnswerRe: Distinct records problem Pin
seea3-Aug-06 0:55
seea3-Aug-06 0:55 
AnswerRe: Distinct records problem Pin
ra ra ra ra3-Aug-06 0:58
ra ra ra ra3-Aug-06 0:58 
GeneralRe: Distinct records problem Pin
psamy3-Aug-06 1:03
psamy3-Aug-06 1:03 
GeneralRe: Distinct records problem Pin
ra ra ra ra3-Aug-06 1:06
ra ra ra ra3-Aug-06 1:06 
GeneralRe: Distinct records problem Pin
seea3-Aug-06 5:41
seea3-Aug-06 5:41 
QuestionSQL Server not running in local Pin
Exelioindia2-Aug-06 19:53
Exelioindia2-Aug-06 19:53 
AnswerRe: SQL Server not running in local Pin
seea3-Aug-06 0:38
seea3-Aug-06 0:38 
QuestionCheckbox in datagrid [modified] Pin
ypsyong2-Aug-06 16:52
ypsyong2-Aug-06 16:52 
QuestionIncorrect syntax, but I can't see it [modified] Pin
Ed.Poore2-Aug-06 2:32
Ed.Poore2-Aug-06 2:32 
AnswerRe: Incorrect syntax, but I can't see it Pin
ToddHileHoffer2-Aug-06 3:14
ToddHileHoffer2-Aug-06 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.