in existing project of combobox not just show the the project No. and also show the textbox of the project name
this is my code is it corrct:
Private Sub DataOfProject_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
Dim sql As String = "Select [ProjectNo] From tbl_assignment "
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
sqlCom.Connection = conn
Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
While sqlReader.Read = True
cbbproject.Items.Add(sqlReader("ProjectNo").ToString)
End While
sqlReader.Close()
sqlCom.Dispose()
conn.Close()
End Sub
Private Sub cbbproject_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbbproject.SelectedIndexChanged
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
Dim sql As String = "Select * From tbl_assignment Where ProjectNo ='" & cbbproject.SelectedItem.ToString & "' AND Projcet Name'" & txtpn.Text & "' "
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
sqlCom.Connection = conn
Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader
While sqlReader.Read = True
txtpn.Text = (sqlReader("Project Name").ToString)
End While
sqlReader.Close()
sqlCom.Dispose()
conn.Close()
End Sub