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


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

Re: Visual studio 2017 - Filtro datagridview

X-Received by 2002:ad4:5587:: with SMTP id e7mr6023791qvx.160.1583406892023; Thu, 05 Mar 2020 03:14:52 -0800 (PST)
X-Received by 2002:a37:7f03:: with SMTP id a3mr7428481qkd.121.1583406891757; Thu, 05 Mar 2020 03:14:51 -0800 (PST)
Path csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.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:14:51 -0800 (PST)
In-Reply-To <e0c93d45-d6ec-4276-a06f-abf0070d7caa@googlegroups.com>
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
References <e0c93d45-d6ec-4276-a06f-abf0070d7caa@googlegroups.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <5e7acb58-9d99-4f6f-95e3-e1aa526a6f1e@googlegroups.com> (permalink)
Subject Re: Visual studio 2017 - Filtro datagridview
From Marco75 <marcoporzi75@gmail.com>
Injection-Date Thu, 05 Mar 2020 11:14:52 +0000
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
Lines 61
Xref csiph.com it.comp.lang.visual-basic:19713

Show key headers only | View raw


Il giorno giovedì 5 marzo 2020 12:01:16 UTC+1, Marco75 ha scritto:
> 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)
> '" & Trim(CbMacina.Text) & "'" & "And Segmento ='" & Trim(CbSegmen
> idee su cosa non funzioni?
> grazie
> Marco

Aggiornamento... così funziona
CreaGriglia("T_RicetteMacine2020", "Select ID, DataOra, Macina, Segmento, Ricetta, Valore1, Valore2, Valore3, Valore4, Valore5 From T_MiaTabella2020 where Macina=" & CbMacina.Text, dgvRicette2)
appena cerco di aggiungere altri filtri non va più!

Back to it.comp.lang.visual-basic | Previous | NextPrevious 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