'here i successfully loaded data to combobox
Private Sub FillCombo()
Try
'Dim fillcon As New OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=path to access file.mdb;")
Dim asql As String = ("SELECT LastName +', '+ FirstName AS FullName FROM tbleMember order by Lastname")
Dim da As New OleDbDataAdapter(asql, MyConn)
Dim ds As New DataSet
da.Fill(ds)
cmbName.ValueMember = "FullName"
cmbName.DataSource = ds.Tables(0)
cmbName.SelectedIndex = 0
Catch ex As Exception
MsgBox("ERROR : " & ex.Message.ToString)
End Try
End Sub
'codes displaying into textbox..
Private Sub cmbName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbName.SelectedIndexChanged
Dim asql As String = ("SELECT * FROM tbleMember where LastName='" & cmbName.Text & "'")
MyConn.Open()
Dim cmd As New OleDbCommand
cmd.CommandText = asql
cmd.Connection = MyConn
dr = cmd.ExecuteReader
If dr.Read = True Then
txtFormNo.Text = dr("FormNo")
End If
MyConn.Close()
End Sub
This post has been edited by smohd: 08 August 2012 - 08:20 AM
Reason for edit:: Code tags added. Please use [code] tags when posting codes

New Topic/Question
Reply



MultiQuote






|