I have a database Linq dbml I need to change the database name before creating
Dim dt As New DataSchool()
dt.Connection.Open()
dt.CreateDatabase()
Use This Method
Sub CreatesqldatabaseMSQL()
Try
Using connect As New DataSchool(GetSQLConnectionString(True))
connect.CreateDatabase()
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
GetSQLConnectionString This Function Return SQLconnection string
Public Function GetSQLConnectionString(ByVal includeDatabase As Boolean) As String
Dim builder As New SqlConnectionStringBuilder()
'Build a connection string from the user input.'
builder.DataSource = Msql.datasource
builder.IntegratedSecurity = Msql.IntSec
If builder.IntegratedSecurity = False Then
builder.UserID = Msql.username
builder.Password = Msql.password
End If
If includeDatabase Then
builder.InitialCatalog = Msql.DatabaseName
End If
Return builder.ConnectionString
End Function
Msql.Server, Msql.DatabaseName and etc this is Structure, You can change database name From here
Public Structure Msql
Shared datasource As String
Shared IntSec As Boolean
Shared username As String
Shared password As String
Shared DatabaseName As String
End Structure
DataSchool? Where is its class?