I am doing a deployment project in that i am calling a sql script to attach sql db by making customaction
i m gettting a erro Incorredt systex near 'Filneme' where i m writing wrong syntax in the following functions
Code:Private Sub ExecuteSql(ByVal databasename As String, ByVal Sql As String) Dim command As New SqlClient.SqlCommand(Sql, masterconnection) 'Initialize the conncetion, open it and set it to the master db masterconnection.ConnectionString = My.Settings.masterConnectionString command.Connection.Open() command.Connection.ChangeDatabase(databasename) Try command.ExecuteNonQuery() Finally 'closing the connection shuld be done in a finally block command.Connection.Close() End Try End Sub Protected Sub AddDBTable(ByVal strDBName As String) Try 'Attaching database 'Creates the batabase ExecuteSql("master", "CREATE DATABASE " & strDBName & "ON ( FILENAME=" & My.Application.Info.DirectoryPath & "\Data\HospData.mdf ) FOR ATTACH") 'Creates the tables ExecuteSql(strDBName, GetSql("sql.txt")) Catch ex As Exception 'reports any erros and abort MsgBox("In execption handler create database: " & ex.Message) Throw ex End Try End Sub Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) MyBase.Install(stateSaver) 'AddDBTable(Me.Context.Parameters.Item("dbname")) AddDBTable("HospData") End Sub


Reply With Quote

