Hello, I have made an Employee Time clock application. I have been working on connecting my application to a MySQL database, I have a textbox wich is used to add an employee name to my database (this is working perfectly.), but I also a combobox where I want the list of Employee names retrieved from the database (this is where my problem is.)
I have looked at a few different forum posts, and I still can't seem to get it to work. With this method it won't connect to my Database, but when I take out this code out everything else connects and works just fine.
Some help would be much appreciated!
Here's my code:
Imports MySql.Data.MySqlClient
Public Class MainForm
Dim str As String
Dim strSQL As String = "SELECT distinct ID, Employee FROM employees"
Dim da As New MySqlDataAdapter(strSQL, conn)
Dim ds As New DataSet
Dim conn As New MySqlConnection
Dim MyCmd As New MySqlCommand("SELECT * FROM users", conn)
Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Try
str = " host = localhost ; username = 'username'; password = 'password'; database= vb_timeclock; pooling = false;"
conn.ConnectionString = str
conn.Open()
da.Fill(ds, "employees")
With (cmbEmployee)
.Items.Add("Select")
.DataSource = ds.Tables("emplyees")
.DisplayMember = "Employee"
.ValueMember = "ID"
.SelectedIndex = 0
End With
Catch ex As Exception
MessageBox.Show("Problem connecting to databese!")
End Try