Click here to Skip to main content
15,885,757 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Setting Priorities for Pre-Requisites Pin
SPSandy21-Mar-14 7:03
SPSandy21-Mar-14 7:03 
GeneralRe: Setting Priorities for Pre-Requisites Pin
Eddy Vluggen21-Mar-14 7:37
professionalEddy Vluggen21-Mar-14 7:37 
GeneralRe: Setting Priorities for Pre-Requisites Pin
SPSandy21-Mar-14 7:47
SPSandy21-Mar-14 7:47 
AnswerRe: Setting Priorities for Pre-Requisites Pin
SPSandy20-Mar-14 4:27
SPSandy20-Mar-14 4:27 
QuestionVB6 Cennect with SQL Server Pin
Ardi Durres15-Mar-14 23:38
Ardi Durres15-Mar-14 23:38 
AnswerRe: VB6 Cennect with SQL Server Pin
Eddy Vluggen16-Mar-14 1:08
professionalEddy Vluggen16-Mar-14 1:08 
Questionchange connection with database on runtime Pin
alejx15-Mar-14 4:25
alejx15-Mar-14 4:25 
AnswerRe: change connection with database on runtime Pin
Dave Kreskowiak15-Mar-14 6:55
mveDave Kreskowiak15-Mar-14 6:55 
There are two things you have to do. The first is change the connection string to whatever you need.

All you have to do is replace the part of the connection string that specifies the database and/or server name the database is on.

The second is that you have to wrap your DbContext class with a partial class and supply a new constructor that accepts a connection string:
VB
Partial Public Class MyDbContext

    Public Sub New(connectionString As String)
        If String.IsNullOrWhiteSpace(connectionString) Then
            Throw New ArgumentNullException("connectionString")
        End If

        Database.Connection.ConnectionString = connectionString
    End Sub

End Class

Whenever you need to create a new instance of your DbContext, you just pass the connection string to the wrapper which will pass it to the ConnectionString property of the DbContext for you.

GeneralRe: change connection with database on runtime Pin
alejx15-Mar-14 8:03
alejx15-Mar-14 8:03 
GeneralRe: change connection with database on runtime Pin
Dave Kreskowiak15-Mar-14 10:01
mveDave Kreskowiak15-Mar-14 10:01 
GeneralRe: change connection with database on runtime Pin
alejx15-Mar-14 11:29
alejx15-Mar-14 11:29 
GeneralRe: change connection with database on runtime Pin
Dave Kreskowiak15-Mar-14 12:11
mveDave Kreskowiak15-Mar-14 12:11 
GeneralRe: change connection with database on runtime Pin
alejx16-Mar-14 6:06
alejx16-Mar-14 6:06 
GeneralRe: change connection with database on runtime Pin
Dave Kreskowiak16-Mar-14 7:25
mveDave Kreskowiak16-Mar-14 7:25 
GeneralRe: change connection with database on runtime Pin
alejx16-Mar-14 8:35
alejx16-Mar-14 8:35 
GeneralRe: change connection with database on runtime Pin
Dave Kreskowiak16-Mar-14 14:15
mveDave Kreskowiak16-Mar-14 14:15 
GeneralRe: change connection with database on runtime Pin
alejx17-Mar-14 5:32
alejx17-Mar-14 5:32 
GeneralRe: change connection with database on runtime Pin
alejx18-Mar-14 4:56
alejx18-Mar-14 4:56 
GeneralRe: change connection with database on runtime Pin
Dave Kreskowiak18-Mar-14 5:44
mveDave Kreskowiak18-Mar-14 5:44 
GeneralRe: change connection with database on runtime Pin
alejx18-Mar-14 6:16
alejx18-Mar-14 6:16 
GeneralRe: change connection with database on runtime Pin
Dave Kreskowiak18-Mar-14 11:13
mveDave Kreskowiak18-Mar-14 11:13 
GeneralRe: change connection with database on runtime Pin
alejx18-Mar-14 12:50
alejx18-Mar-14 12:50 
GeneralRe: change connection with database on runtime Pin
Dave Kreskowiak18-Mar-14 13:31
mveDave Kreskowiak18-Mar-14 13:31 
GeneralRe: change connection with database on runtime Pin
alejx18-Mar-14 14:35
alejx18-Mar-14 14:35 
QuestionCopy scanned files Pin
Otekpo Emmanuel12-Mar-14 13:59
Otekpo Emmanuel12-Mar-14 13:59 

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.