Connecting Multiple SQL Databases using INI File in

Lalit Source

I am having below mention code I am using it for connect only one database .But in order to Connect the multiple database How should I do the corrections Consider I am having two databases Databse "ABC" AND Database"XYZ"

 Imports System.Windows.Forms
 Imports System.IO 
 Imports System.Data.SqlClient
 Imports System.Data.OleDb

Public Class Form1
Dim File1 = System.Windows.Forms.Application.StartupPath & "\Conn.ini"
Dim Connection = "Connections"
Dim sname = "sname"
Dim Dbase = "Dbase"
Dim Uname = "uname"
Dim Password = "password"
Dim servername = ReadIni(File1, Connection, sname, "")
Dim database = ReadIni(File1, Connection, Dbase, "")
Dim usname = ReadIni(File1, Connection, Uname, "")
Dim pwd = ReadIni(File1, Connection, Password, "")
Dim conn As New SqlConnection
Dim CMD, cmd1, cmd2, cmd3 As New SqlCommand
Dim str As String = "Data Source='" & servername & "' ;Initial Catalog='"      & database & "' ;User Id='" & usname & "';Password='" & pwd & "'"

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    conn.ConnectionString = str
    CMD.Connection = conn
End Sub


comments powered by Disqus