Dear All,
im using vs 2013 and ms access 2010 (*.accdb)
i had some problem on this code below, basically the function i want when the combobox are selected then it will search the data in the database then show at the textbox. Thanks for helping
The Error as below :
The Code as below :
Dim con2 As New OleDb.OleDbConnection
Dim dbProvider2 As String
Dim dbSource2 As String
Dim ds2 As New DataSet
Dim da2 As OleDb.OleDbDataAdapter
Dim sql2 As String
Private Sub enamecombo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles enamecombo.SelectedIndexChanged
dbProvider2 = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
dbSource2 = "Data Source = |DataDirectory|\empdb.accdb"
con2.ConnectionString = dbProvider2 & dbSource2
Try
eictextbox.Clear()
con2.Open()
sql2 = "Select eic from tblemp where ename = '" & enamecombo.Text & "' "
da2 = New OleDb.OleDbDataAdapter(sql2, con2)
da2.Fill(ds2, "tblemp")
Dim command2 As New System.Data.OleDb.OleDbCommand(sql2, con2)
Dim reader2 As System.Data.OleDb.OleDbDataReader = command2.ExecuteReader()
While reader2.Read()
eictextbox.Text = reader2.GetString("eic") <----- the eic at the database is as text
End While
reader2.Close()
con2.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
im using vs 2013 and ms access 2010 (*.accdb)
i had some problem on this code below, basically the function i want when the combobox are selected then it will search the data in the database then show at the textbox. Thanks for helping
The Error as below :
The Code as below :
Dim con2 As New OleDb.OleDbConnection
Dim dbProvider2 As String
Dim dbSource2 As String
Dim ds2 As New DataSet
Dim da2 As OleDb.OleDbDataAdapter
Dim sql2 As String
Private Sub enamecombo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles enamecombo.SelectedIndexChanged
dbProvider2 = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
dbSource2 = "Data Source = |DataDirectory|\empdb.accdb"
con2.ConnectionString = dbProvider2 & dbSource2
Try
eictextbox.Clear()
con2.Open()
sql2 = "Select eic from tblemp where ename = '" & enamecombo.Text & "' "
da2 = New OleDb.OleDbDataAdapter(sql2, con2)
da2.Fill(ds2, "tblemp")
Dim command2 As New System.Data.OleDb.OleDbCommand(sql2, con2)
Dim reader2 As System.Data.OleDb.OleDbDataReader = command2.ExecuteReader()
While reader2.Read()
eictextbox.Text = reader2.GetString("eic") <----- the eic at the database is as text
End While
reader2.Close()
con2.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub