nhonoskywalker
Member
- Joined
- Jun 7, 2012
- Messages
- 5
- Programming Experience
- Beginner
I searched google and youtube for tutorials they made with their codes but mine NOT..
Please tell me hot to do it with my code or tell me what is wrong..
it is the Imports MySql.Data.MySqlClient ? Because I didnt saw this code from their tutorials.
Imports MySql.Data.MySqlClient
Public class main
Private Sub cboemprecDept_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboemprecDept.Click
cboDept_load()
End Sub
Private Sub cboDept_load()
Dim strsql As String
Dim sqlCommand As New MySqlCommand
If sConnection.State = ConnectionState.Closed Then
sConnection.ConnectionString = "SERVER = localhost; USERID = root; PASSWORD = 1111111; DATABASE = ftenn;"
sConnection.Open()
End If
Dim reader As MySqlDataReader = sqlCommand.ExecuteReader
strsql = "SELECT * FROM dept_tab"
With sqlCommand
.CommandText = strsql
.Connection = sConnection
.ExecuteNonQuery()
End With
While reader.Read
With cboemprecDept.Items.Add(reader("dept_id"))
End With
End While
sConnection.Close()
End Sub
End Class
Please tell me hot to do it with my code or tell me what is wrong..
it is the Imports MySql.Data.MySqlClient ? Because I didnt saw this code from their tutorials.
Imports MySql.Data.MySqlClient
Public class main
Private Sub cboemprecDept_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboemprecDept.Click
cboDept_load()
End Sub
Private Sub cboDept_load()
Dim strsql As String
Dim sqlCommand As New MySqlCommand
If sConnection.State = ConnectionState.Closed Then
sConnection.ConnectionString = "SERVER = localhost; USERID = root; PASSWORD = 1111111; DATABASE = ftenn;"
sConnection.Open()
End If
Dim reader As MySqlDataReader = sqlCommand.ExecuteReader
strsql = "SELECT * FROM dept_tab"
With sqlCommand
.CommandText = strsql
.Connection = sConnection
.ExecuteNonQuery()
End With
While reader.Read
With cboemprecDept.Items.Add(reader("dept_id"))
End With
End While
sConnection.Close()
End Sub
End Class