Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai All,
I am developing one VB Application whose has Read&write the data into Access table. and i am completing the write section as mention as below. Now i need to read the data from Access Table to GridView for every 60 sec.
This is the code iam used to write the data into Access.

VB
Dim cnnOLEDB As New OleDbConnection
    Dim cmdOLEDB As New OleDbCommand
    Dim cmdInsert As New OleDbCommand
    Dim cmdUpdate As New OleDbCommand
    Dim cmdDelete As New OleDbCommand
    Dim adpOLEDB As New OleDbDataAdapter
    Dim strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.Environment.CurrentDirectory & "\SMSDB.mdb"


SQL
cmdInsert.CommandText = "INSERT INTO SMSDATA1DB (Start_Of_Packet, Packet_Identifier) VALUES ('" & STX1 & "', '" & STX2 & "')"
        MsgBox(cmdInsert.CommandText)
        cmdInsert.CommandType = CommandType.Text
        cmdInsert.Connection = cnnOLEDB
        cmdInsert.ExecuteNonQuery()
        cmdInsert.Dispose()


VB
Private Sub DataPreview_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cnnOLEDB.ConnectionString = strConnectionString
        cnnOLEDB.Open()
End Sub



Any Body Help me.........
Posted

1 solution

VB
Dim dt1 As New DataTable()
    dt1.Clear()
    Dim adp As New OleDb.OleDbDataAdapter("SELECT * FROM SMSDATA1DB", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.Environment.CurrentDirectory & "\SMSDB.mdb")
    adp.Fill(dt1)
    adp.Dispose()
    DataGridView1.DataSource = dt1



Use this code to retrieve data form access table....:) This is Improved solution use this.....:)
 
Share this answer
 
v2
Comments
Himachandra 30-Nov-11 1:35am    
Yahhhhh....... ITZ Working........ Thank You So much
Himachandra 30-Nov-11 1:59am    
WHENEVER I AM USING THIS

"SELECT * FROM DatTime ORDER BY DATE&TIME DESC", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Alram.mdb"

RUNTIME ERROR HAS BEEN COMING ............
I NEED TO ORDER BY DATE&TIME COLUMN THAT TO IN DESC
PLZZZ HELP ME LOL.......
NikulDarji 30-Nov-11 3:42am    
Hey.....this is my code....U have to change as per your requirement....:)
I m improving my solution....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900