TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohammad Ishaq
NA
55
19k
Correction Req For Combo box code
May 31 2014 4:18 PM
Hello
I m using VB 2008 and Access 2007.
Access File Name : a
Access Table Name: emp
data source=E:\a
one combobox : ComboBox1
My Access have 4 columns "EmpID",EmpName","Disgination",GrossSalary",.
I want that the combo box pick the data of EmpName automatically . I have try three type of codes but every code shows error "
could not find the file E:\a.mdb.
I check the path several time and confirm the path.some time the code execute but the combo box show nothing.
I am very disturb due to this problem.Because of this one of my project has been stopped.I request to any experience person to help me and given me a simple and clean code according to my needs.And also let me clear that why i m facing this problems.The code i m used are given below.For better . Thanks
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=E:\a.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT EmpName FROM emp", con)
con.Open()
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "emp")
'Idea 1
ComboBox1.DataSource = myDataSet.Tables("emp").DefaultView
ComboBox1.ValueMember = "EmpName"
ComboBox1.DisplayMember = "EmpName"
'Idea 2
'For Each dRow As DataRow In myDataSet.Tables("emp").Rows
'ComboBox1.Items.Add(dRow.Item("EmpID"))
'Next
'Idea 3
'Dim sdr As OleDbDataReader = cmd.ExecuteReader
'While sdr.Read()
'ComboBox1.Items.Add(sdr.Item("emp").ToString)
'End While
con.Close()
con = Nothing
End Sub
Attachment:
scr.zip
Reply
Answers (
1
)
What do you think the use of Ribbon Control
Datatable cell to list & using string list in Legends