Connection to MSAccess

Posts   
 
    
avarndel
User
Posts: 36
Joined: 14-Jun-2007
# Posted on: 20-Jun-2007 21:37:25   

Please excuse me for my ignorance. I'm very new to your product and .net. I need to create a gridview on the fly that will populate the column headers and data based on an access 2003 database.

I have my llBLGen projBud referenced in my VS 2005 project. I'm also using the Access Adapter.

Your Documentation is not written in laymen's terms. So I'm sure I'm missing something huge.

How do I return all the data in a table FeeCol ?

This is what I have so far:

    Dim Adapter = New DataAccessAdapter()
    Dim queryToExecute As IActionQuery
    Dim queryToExecute2 As IActionQuery
    Dim value As Integer
    Dim value2 As Integer
    Adapter.OpenConnection()

    'Gets the column names
    queryToExecute = "Select * from ORevCol where CompanyID=1"
    value = Adapter.ExecuteActionQuery(queryToExecute)

    'add column names
    While value <> 0
        Grid1.MasterTableView.Name = value
    End While

    'Get Data for columns
    queryToExecute2 = "Select * from ProjBud where Officeid ='" & OfficeID.Text & "', ProjProfID='" & ProjectID.Text & "'"
    value2 = Adapter.ExecuteActionQuery(queryToExecute2)

If value2 <> 0 Then Grid1.DataSource = Adapter End If

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39912
Joined: 17-Aug-2003
# Posted on: 20-Jun-2007 22:33:33   

avarndel wrote:

Please excuse me for my ignorance. I'm very new to your product and .net. I need to create a gridview on the fly that will populate the column headers and data based on an access 2003 database.

I have my llBLGen projBud referenced in my VS 2005 project. I'm also using the Access Adapter.

Your Documentation is not written in laymen's terms. So I'm sure I'm missing something huge.

How do I return all the data in a table FeeCol ?

This is what I have so far:

    Dim Adapter = New DataAccessAdapter()
    Dim queryToExecute As IActionQuery
    Dim queryToExecute2 As IActionQuery
    Dim value As Integer
    Dim value2 As Integer
    Adapter.OpenConnection()

    'Gets the column names
    queryToExecute = "Select * from ORevCol where CompanyID=1"
    value = Adapter.ExecuteActionQuery(queryToExecute)

    'add column names
    While value <> 0
        Grid1.MasterTableView.Name = value
    End While

    'Get Data for columns
    queryToExecute2 = "Select * from ProjBud where Officeid ='" & OfficeID.Text & "', ProjProfID='" & ProjectID.Text & "'"
    value2 = Adapter.ExecuteActionQuery(queryToExecute2)

If value2 <> 0 Then Grid1.DataSource = Adapter End If

Don't use ExecuteActionQuery, you don't need to do that.

Simply use this code:


Dim values As New EntityCollection(Of FeeColEntity)
Using adapter As New DataAccessAdapter()
    adapter.FetchEntityCollection(values)
End Using

' bind to grid
Grid1.DataSource = values

That's it. simple_smile

Frans Bouma | Lead developer LLBLGen Pro