Imports System.Data
Imports System.Data.SqlClient
Module Module_all
Friend strConnString As String = "Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\VB\Bank_Project\DB\DB1.mdf;Integrated Security=True;Connect Timeout=1000"
Friend objCmd As New SqlCommand
Friend objConn As New SqlConnection
Friend sql As String
End Module
หน้า Form Code
objConn.ConnectionString = strConnString
Try
objConn.Open()
Catch ex As Exception
MessageBox.Show("เชื่อมต่อฐานข้อมูลล้มเหลว")
End Try