P2Pprogrammer 2 programmer


Home > Programmer2Programmer.NET Forum> ADO.NET, Entity Framework, Linq >> How to display data in datagrid from access table?...

Welcome Guest My Thread | Search | Active Topics | Members | Log In | Register

NOTE : Log In required to post Replies for this discussion.
How to display data in datagrid from access table?
AJProfessionals Posted: Friday 09, May 2008 03:44:00 PM     
   
I have a table in MS Access, now how i can display 
data in datagrid?

show me the code.
Back to Top ^  
 Coder Posted: Friday 09, May 2008 03:46:17 PM
  
   
Use following code to diaplay data in datagrid.
In this example daatabase name is data.mdb
Table name is "user"


Dim Cn As New OleDb.OleDbConnection
If Cn.State = 1 Then Cn.Close()
Cn.ConnectionString = "Provider=microsoft.jet.oledb.4.0; data s
ource=c:\data.mdb"
Cn.Open()
Dim Cmd As New OleDb.OleDbCommand
Com.CommandType = CommandType.Text
Qry=“select * from user”
Com.CommandText = qry
Com.Connection = CN
Ds.clear()
Dim Da As New Oledb.OledbDataAdapter(qry, CN)
Da.Fill(ds, "user")
Dg1.DataSource = ds
Dg1.DataMember = "user"
Dg1.Refresh()
Com.dispose()
Cn.close()


--Coder

Back to Top ^ 


Home > Programmer2Programmer.NET Forum >ADO.NET, Entity Framework, Linq >> How to display data in datagrid from access table?...