Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
VB
Public Class Form1
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim tb As DataTable

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con = New ADODB.Connection
        rs = New ADODB.Recordset
        tb = New DataTable
        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\AMEER & SONS\AMEER&SONS.mdb;Persist Security Info=False"
        con.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        con.Open()
        rs.Open("company_info", con, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, 2)
        grid.DataSource = rs
    End Sub
End Class

This code does not show the error message but datagridview does not show data why? Thanks in advanced.

Edit TR : Please read the posting guidelines and do not SHOUT.
Posted
Updated 15-Apr-10 11:14am
v3

You havn't mapped any data to your DataTable, which you would use to fill the Grid:

tb = New DataTable
...
grid.DataSource = tb
 
Share this answer
 
Comments
Member 10403037 15-Feb-14 18:56pm    
how to fill the grid?
rs.Open("ventas", con, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, 2)
Form10.DataGridView1.DataSource = tb

Would be someting like this?
 
Share this answer
 
VB
Public Class Form1
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim tb As DataTable
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con = New ADODB.Connection
        rs = New ADODB.Recordset
        tb = New DataTable
        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\AMEER & SONS\AMEER&SONS.mdb;Persist Security Info=False"
        con.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        con.Open()
        rs.Open("company_info", con, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, 2)

        Dim da As New System.Data.OleDb.OleDbDataAdapter()
        Dim ds As New DataSet()
        da.Fill(ds, rs, "company_info")

        'rs.Close()  'Cannot close in this method
        rs.ActiveConnection = Nothing
        con.Close()
        rs = Nothing
        con = Nothing

        grid.DataSource = (ds.Tables("company_info"))
    End Sub
End Class
 
Share this answer
 
v2

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