Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Sub Page_Load(sender As Object, e As EventArgs)
Dim strConnString As String
strConnString = "Server=localhost;Uid=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
objConn = New SqlConnection(strConnString)
objConn.Open()
BindData()
End Sub
Sub BindData()
Dim strSQL As String
strSQL = ""
strSQL = strSQL & "SELECT Col1,Col2,Col3 FROM customer1 WHERE Col1 LIKE '%" & strKeyword & "%' "
strSQL = strSQL & "UNION ALL "
strSQL = strSQL & "SELECT Col1,Col2,Col3 FROM customer2 WHERE Col1 LIKE '%" & strKeyword & "%'"
strSQL = strSQL & "UNION ALL "
strSQL = strSQL & "SELECT Col1,Col2,Col3 FROM customer3 WHERE Col1 LIKE '%" & strKeyword & "%'"
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to GridView ***'
myGridView.DataSource = dtReader
myGridView.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub