Am just new to vb 2010 and am trying to fetch data from access database (Employees.mdb) but am stack on how to display the data now, anybody with help. Thanks
Public Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim LoginUser As String
LoginUser = LoginForm.TextBoxID.Text ' User Login Name
DisplayLogin.Text = LoginUser ' Display now user to form
Dim db As String = "Employees.mdb"
Dim DatabasePath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\QBook Api\data api\" + db
If My.Computer.FileSystem.FileExists(DatabasePath) Then
Dim con As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim Sql As String
Dim NumOfRows As Integer
Dim TodayDate As String = Today
con.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0; Data Source = " + DatabasePath
con.Open() ' Opening oLe Connection
' Checking database if we have todays or Searched records
Sql = "SELECT * FROM Employees INNER JOIN TimeTable ON Employees.EmployeeNo = TimeTable.RefID WHERE Dated = '" & TodayDate & "' "
cmd = New OleDb.OleDbCommand(Sql, con)
NumOfRows = cmd.ExecuteScalar()
cmd.ExecuteNonQuery()
If NumOfRows > 0 Then
' Here I need to display the data
Else
MsgBox("Sorry we don’t have Entry Logs of (" + TodayDate + ")", MsgBoxStyle.Critical, Title:="QBook - No entry found")
End If
con.Close() ' Closing Connection
Else
MsgBox("Unable to get database file in (" + DatabasePath + ")", MsgBoxStyle.Critical)
End If ' no database found
End Sub
any suggestion is appreciated and welcomed
Aucun commentaire:
Enregistrer un commentaire