VB.NET Visual Basic Ottenere con ricerca random solo le date che corrispondono a dati presenti

Michele Signo 1 Reputation point
2022-05-12T15:25:30.433+00:00

Ciao A tutti, ho un problema che non riesco a risolvere. Ho creato con un pulsante la possibilità di cercare attraverso 2 DateTimePichker (1 e 2)la ricerca mirata, in questo caso solo il sabato, di dati che ho in tabella e che visualizzo con DataGridView.
Quello che vorrei è che nel random dei sabati, passasse oltre quando il sabato non corrisponde a dati presenti in DataGridView.
Come fare?
Qui di seguito il mio codice:

Private Sub btnSabatoVecchio_Click(sender As Object, e As EventArgs) Handles btnSabatoVecchio.Click
d1.Value = GetRandomDate(d1.MinDate, d1.MaxDate)
Dim table As New DataTable()
Dim command As New SqlCommand("SELECT * FROM LottoDeaBendata WHERE [Data] BETWEEN @d1 AND @d2", connection)
d1.Value = d1.Value.AddDays(DayOfWeek.Sunday - (d1.Value.DayOfWeek + 1))
d2.Value = d1.Value
command.Parameters.Add("@d1", SqlDbType.Date).Value = d1.Value
command.Parameters.Add("@d2", SqlDbType.Date).Value = d2.Value
Dim adapter As New SqlDataAdapter(command)
adapter.Fill(table)
DataGridView1.DataSource = table
End Sub

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
40,274 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-05-12T15:45:02.273+00:00

    Q&A forums are currently English only. I'd try asking for help over here in dedicated forums.
    https://social.msdn.microsoft.com/Forums/it-it/home
    https://social.technet.microsoft.com/Forums/it-it/home
    https://answers.microsoft.com/it-it

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.