Results 1 to 10 of 10

Thread: [RESOLVED] sql script for attaching db in deployment project vb.net2005

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member yousufkhan's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    492

    Resolved [RESOLVED] sql script for attaching db in deployment project vb.net2005

    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
    Last edited by yousufkhan; Aug 18th, 2012 at 04:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width