• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Add access dbase to DataGridView VB.net

Hello all

I'm trying it insert data from my Access DBase into my DataGridView, based on some column.

The problem is on that part of the code:
 Me.sauvegarde.AddItem(oRST2("Client") & vbTab & (oRST2("Telephone")) & vbTab & oRST2("Type_Boisson") & vbTab & oRST2("No_Lot") & vbTab & oRST2("Date_Depart") & vbTab & oRST2("Date_Soutirage") & vbTab & oRST2("Date_Stabilisation") & vbTab & oRST2("Date_Filtration") & vbTab & oRST2("Date_Embouteillage") & vbTab & oRST2("Genre_Boisson") & vbTab & oRST2("Notes") & vbTab)

Open in new window


It say Additem is not a member of System.Windows.Forms.DataGridView.

Can you help me with This please?

Thanks again for your help.


Option Explicit On
Imports Microsoft.Office.Interop
Imports System.Reflection
Imports Microsoft.Office.Interop.Access



  Dim sSQL2 As String
        Dim oRST2 As ADODB.Recordset
        oRST2 = New ADODB.Recordset
        Dim oConnect2 As ADODB.Connection
        oConnect2 = New ADODB.Connection


        oConnect2.Open("Provider=Microsoft.ACE.OLEDB.12.0;" & _
         "Data Source=" & Form4.base_de_donnee.Text)


        sSQL2 = "SELECT [Client],[Telephone],[Type_Boisson],[No_Lot],[Date_Depart],[Date_Soutirage],[Date_Stabilisation],[Date_Filtration],[Date_Embouteillage],[Genre_Boisson],[Notes] FROM [DBase_Vignoble] Where " _
        & "Date_Depart => '" & DateTimePicker1.Text & "' OR " _
         & "Date_Depart =< '" & DateTimePicker2.Text & "'"

        sSQL2 = sSQL2 & " ORDER BY [Date_Depart]"

        oRST2.Open(sSQL2, oConnect2)

        If oRST2.BOF = False Then

            Do Until oRST2.EOF
                Me.sauvegarde.AddItem(oRST2("Client") & vbTab & (oRST2("Telephone")) & vbTab & oRST2("Type_Boisson") & vbTab & oRST2("No_Lot") & vbTab & oRST2("Date_Depart") & vbTab & oRST2("Date_Soutirage") & vbTab & oRST2("Date_Stabilisation") & vbTab & oRST2("Date_Filtration") & vbTab & oRST2("Date_Embouteillage") & vbTab & oRST2("Genre_Boisson") & vbTab & oRST2("Notes") & vbTab)
                oRST2.MoveNext()
            Loop

        End If
    End Sub

Open in new window

0
Wilder1626
Asked:
Wilder1626
1 Solution
 
tumtum73Commented:
I believe you need to use the "Me.sauvegarde.Rows.Add()" function on line 30.

Please see the MSDN reference located at:

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx#Y228
0
 
Wilder1626Author Commented:
Thanks for your help.

That was not to hard to fix, but very simple.

Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now