Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.visual-basic > #19712

Visual studio 2017 - Filtro datagridview

X-Received by 2002:a37:a08b:: with SMTP id j133mr3049187qke.265.1583406074447; Thu, 05 Mar 2020 03:01:14 -0800 (PST)
X-Received by 2002:a37:b304:: with SMTP id c4mr7549067qkf.348.1583406074175; Thu, 05 Mar 2020 03:01:14 -0800 (PST)
Path csiph.com!xmission!news.alt.net!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups it.comp.lang.visual-basic
Date Thu, 5 Mar 2020 03:01:13 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info google-groups.googlegroups.com; posting-host=213.215.169.20; posting-account=yvxj_woAAABxrxq8XihQzP-tWUWpycQc
NNTP-Posting-Host 213.215.169.20
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <e0c93d45-d6ec-4276-a06f-abf0070d7caa@googlegroups.com> (permalink)
Subject Visual studio 2017 - Filtro datagridview
From Marco75 <marcoporzi75@gmail.com>
Injection-Date Thu, 05 Mar 2020 11:01:14 +0000
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
Lines 53
Xref csiph.com it.comp.lang.visual-basic:19712

Show key headers only | View raw


Ciao,
ho importato in VS2017 un progetto creato con una vecchia versione (mi sembra VS2008) ed ora non mi funziona più un filtro su datagridview...

di seguito il codice che popola il datagridview su load della maschera:

Private Sub CreaGriglia(ByVal NomeTab2 As String, ByVal Query As String, ByVal dgv As DataGridView)

        
        Dim cn2 As New OdbcConnection("DRIVER=SQL Server;SERVER=NomeServer;Uid=xxxx;Pwd=yyyy;DATABASE=miodatabase;")
        cn2.Open()

        Dim command2 As New OdbcCommand(Query, cn2)
        Dim da2 As New OdbcDataAdapter With {
            .SelectCommand = command2
        }

        Dim ds2 As New DataSet(NomeTab2)
        ds2.Clear()

        da2.Fill(ds2, NomeTab2)

        dgv.DataSource = ds2.Tables(NomeTab2).DefaultView
        'Combo.DisplayMember = "ID"

    End Sub

Private Sub FrmRicette_FlowChart_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

CreaGriglia("T_RicetteMacine2020", "Select ID, DataOra, Macina, Segmento, Ricetta, Valore1, Valore2, Valore3, Valore4, Valore5 From T_MiaTabella2020 order by DataOra Desc", dgvRicette2)

dove dgvRicette2 è la mia datagridview
End Sub

ora, io dovrei fare questo:
popolo 3 combo (Macina, Segmento, Ricetta)
su click di un pulsante devo eseguire una query che prende i dati dalle 3 combo e mi dovrebbe rendere un solo record in datagridview (cosa che ora non sta facendo). questo il codice che uso ora:

CreaGriglia("T_RicetteMacine2020", "Select ID, DataOra, Macina, Segmento, Ricetta, Valore1, Valore2, Valore3, Valore4, Valore5 From T_MiaTabella2020 where Macina ='" & Trim(CbMacina.Text) & "'" & "And Segmento ='" & Trim(CbSegmento.Text) & "'" & "And Ricetta ='" & Trim(CbRicetta.Text) & "'" & "order by DataOra Desc", dgvRicette2)

idee su cosa non funzioni?
grazie
Marco

Back to it.comp.lang.visual-basic | Previous | NextNext in thread | Find similar


Thread

Visual studio 2017 - Filtro datagridview Marco75 <marcoporzi75@gmail.com> - 2020-03-05 03:01 -0800
  Re: Visual studio 2017 - Filtro datagridview Marco75 <marcoporzi75@gmail.com> - 2020-03-05 03:14 -0800

csiph-web