Private Sub search_name()
Dim myConn As SqlConnection
myConn = New SqlConnection(ConfigurationManager.ConnectionStrings("PhoneBook_2ConnectionString").ConnectionString)
Dim myCommand As SqlCommand = New SqlCommand()
myCommand.CommandText = "SELECT [Users].Name_TH AS 'ชื่อ', [Users].Surname_TH AS 'นามสกุล', Dept.Department AS 'แผนก/สาขา', Position.Position AS 'ตำแหน่ง', [Users].Tel AS 'เบอร์โทร', [Users].Tex_Ext AS 'เบอร์ต่อ',[Users].ID"
myCommand.CommandText &= " FROM [Users] INNER JOIN Dept ON [Users].ID_Dept = Dept.ID_Dept INNER JOIN Position ON [Users].ID_Position = Position.ID_Position "
myCommand.CommandText &= " WHERE Users.Name_TH LIKE '%" & TextBox1.Text & "%'"
myCommand.CommandType = CommandType.Text
myCommand.Connection = myConn
myCommand.Connection.Open()
Dim myReader2 As SqlDataReader
myReader2 = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
GridView1.DataSource = myReader2
GridView1.DataBind()
myCommand.Dispose()
myConn.Dispose()
End Sub