M
muhammadanzar
Guest
hi
Table 1 Employee
id | Name
1 | Anzar
Table 2 Product
Id| Name | EmployeeID '(foreign key)
5 |apple | 1
my code given below it. Required is when take value as EmployeeName for product table but insert into table in employeeid
in product table. employee name is easy to remember but id is difficult to remember.
employeeId as foreign key in product table
Try
'=============================
'textbox show dropdown list take data from database
Dim connection1 As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Dim command1 As New SqlCommand("SELECT * FROM employees", connection1)
Dim table1 As New DataTable
Dim adapter1 As New SqlDataAdapter(command1)
Dim col As New AutoCompleteStringCollection
adapter1.Fill(table1)
For i = 0 To table1.Rows.Count - 1
col.Add(table1.Rows(i)("EmployeeName").ToString())
Next
Textbox3.AutoCompleteSource = AutoCompleteSource.CustomSource
Textbox3.AutoCompleteCustomSource = col
Textbox3.AutoCompleteMode = AutoCompleteMode.SuggestAppend
Catch ex As Exception
MsgBox(ex.Message)
Finally
End Try
End Sub
MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959
Continue reading...
Table 1 Employee
id | Name
1 | Anzar
Table 2 Product
Id| Name | EmployeeID '(foreign key)
5 |apple | 1
my code given below it. Required is when take value as EmployeeName for product table but insert into table in employeeid
in product table. employee name is easy to remember but id is difficult to remember.
employeeId as foreign key in product table
Try
'=============================
'textbox show dropdown list take data from database
Dim connection1 As New SqlConnection("Data Source=.\SQLExpress;Initial Catalog=k1;Integrated Security=True")
Dim command1 As New SqlCommand("SELECT * FROM employees", connection1)
Dim table1 As New DataTable
Dim adapter1 As New SqlDataAdapter(command1)
Dim col As New AutoCompleteStringCollection
adapter1.Fill(table1)
For i = 0 To table1.Rows.Count - 1
col.Add(table1.Rows(i)("EmployeeName").ToString())
Next
Textbox3.AutoCompleteSource = AutoCompleteSource.CustomSource
Textbox3.AutoCompleteCustomSource = col
Textbox3.AutoCompleteMode = AutoCompleteMode.SuggestAppend
Catch ex As Exception
MsgBox(ex.Message)
Finally
End Try
End Sub
MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959
Continue reading...