Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Text
Public Class WebForm1
Inherits System.Web.UI.Page
Dim dtt As DataTable
Dim dt As DataTable
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Dim ArrTest() As String = {"INF","SD"}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConnString As String
strConnString = "Server=ชื่อ server;Database=HR;Integrated Security=True"
objConn = New SqlConnection(strConnString)
objConn.Open()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim dtReader As SqlDataReader
' For i As Integer = 0 To ArrTest.Length - 1
Dim sql = "select Employee.Department_Name,Employee.Employee_ID,Employee.Employee_FirstName,Employee.Employee_LastName,Time.Card_Date From Employee LEFT Join Time ON Employee.Employee_ID = Time.Employee_ID where Employee.Department_Name ='" & ArrTest(0) & "' AND Employee.Employee_Status = 'TRUE' AND Time.Card_Date = '20/5/2557'" +
" UNION" +
" select Employee.Department_Name,Employee.Employee_ID,Employee.Employee_FirstName,Employee.Employee_LastName,Emp_Vacation.Vacation_Date From Employee LEFT Join Emp_Vacation ON Employee.Employee_ID = Emp_Vacation.Employee_ID where Employee.Department_Name ='" & ArrTest(0) & "' AND Employee.Employee_Status = 'TRUE' AND Emp_Vacation.Vacation_Date = '20/5/2557'"
objCmd = New SqlCommand(sql, objConn)
dtReader = objCmd.ExecuteReader()
myDataGrid.DataSource = dtReader
myDataGrid.DataBind()
dtReader.Close()
'dt = GetData(sql, StrConnDB)
'dtt = dt
'Next
'myDataGrid.DataSource = dtt
'myDataGrid.DataBind()
End Sub
End Class
Tag : ASP, Web (ASP.NET), VB.NET, VS 2010 (.NET 4.x)