17-06-13, 05:16 PM
السلام عليكم
تفضل
تفضل
PHP كود :
Imports System.Data.SqlClient
Public Class Form1
Private constr As String = "Data Source=.\SQLEXPRESS;Initial Catalog=Emp;Integrated Security=True;"
Private mycon As New SqlConnection(constr)
Private myadapter As New SqlDataAdapter()
Private mytable As New DataTable()
Private myset As DataSet
Private emp As New List(Of Object)
Private Sub connect(ByVal select1 As String)
myadapter = New SqlDataAdapter(select1, mycon)
myset = New DataSet()
mycon.Open()
myadapter.Fill(myset)
mytable = myset.Tables(0)
mycon.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
connect("select * from Emp_Tbl,EmpInfo_Tbl,Dep_Tbl where Emp_Tbl.ID=EmpInfo_Tbl.Info_EmpID and EmpInfo_Tbl.Info_Department=Dep_Tbl.ID")
For i = 0 To mytable.Rows.Count - 1
ListBox1.Items.Add(mytable.Rows(i)("Dep_Name").ToString())
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
connect("select * from Emp_Tbl,EmpInfo_Tbl,Dep_Tbl where Emp_Tbl.ID=EmpInfo_Tbl.Info_EmpID and EmpInfo_Tbl.Info_Department=Dep_Tbl.ID and Dep_Tbl.Dep_Name='" & ListBox1.Text & "'")
DataGridView1.DataSource = mytable
End Sub
End Class
