Click here to Skip to main content
15,352,155 members
Please Sign up or sign in to vote.
2.60/5 (5 votes)
See more:
I am new in vb6 but I had made the connection by using Microsoft.Jet.OLEDB.4.0;Data
And the MS Access Data and viewed it in MSFlxeGrid it works properly but now I wants to use same code in VB2010 but it does not work pls help me.

Thank in advance

VB
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\myAccess2007file.accdb;Persist Security Info=False;
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WINDOWS\system32\Customer\CustData.mdb;Persist Security Info=False"
rs.Open QRY, cn, adOpenStatic

If rs.RecordCount = 0 Then

Else

MSFlexGrid1.Cols = 4
MSFlexGrid1.Rows = rs.RecordCount + 1     
  
MSFlexGrid1.Col = 0
Label1.Caption = rs.Fields(0)
MSFlexGrid1.Row = 0
MSFlexGrid1.Text = "NAME"

MSFlexGrid1.Col = 1
Label2.Caption = rs.Fields(1)
MSFlexGrid1.Row = 0
MSFlexGrid1.Text = "ADDRESS"

MSFlexGrid1.Col = 2
Label3.Caption = rs.Fields(2)
MSFlexGrid1.Row = 0
MSFlexGrid1.Text = "D.O.B."

MSFlexGrid1.Col = 3
Label4.Caption = rs.Fields(3)
MSFlexGrid1.Row = 0
MSFlexGrid1.Text = "TELEPHONE"

For I = 1 To rs.RecordCount

MSFlexGrid1.Col = 0
MSFlexGrid1.Row = I
MSFlexGrid1.Text = rs.Fields(0)

MSFlexGrid1.Col = 1
MSFlexGrid1.Row = I
MSFlexGrid1.Text = rs.Fields(1)

MSFlexGrid1.Col = 2
MSFlexGrid1.Row = I
MSFlexGrid1.Text = rs.Fields(2)
MSFlexGrid1.CellBackColor = vbRed

MSFlexGrid1.Col = 3
MSFlexGrid1.Row = I
MSFlexGrid1.Text = rs.Fields(3)
MSFlexGrid1.CellBackColor = vbRed

rs.MoveNext

Next I

End If



[edit] separate text from code inside the tags [/edit]
Posted
Updated 31-May-12 9:03am
v5
Comments
Sergey Alexandrovich Kryukov 24-Apr-12 14:42pm
   
If you are new to VB6, what makes you getting into this trouble? :-)
--SA
DKarles 24-Apr-12 14:48pm
   
thanks for your valuable advise
Sergey Alexandrovich Kryukov 25-Apr-12 16:41pm
   
You are very welcome. It can really make your life a lot easier... :-)
--SA
Himachandra 27-Apr-12 7:21am
   
Reason for my vote of 5
NICE...
Jack_321 9-May-12 15:31pm
   
please check your grammar & spelling before you post a question. The head of the question should be How to "Connect" ms-access using vb.net / vb 2010.
DKarles 31-May-12 15:06pm
   
thank u Jack_321 i had made rectification as per your suggestion

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