this shouldn't be hard to do but still i don't know it. i'm trying to show data in grid based on date selected in datetimepicker.
My code:
Private Sub kalendar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kalendar.ValueChanged
Const dbCS As String = "Data Source=GORAN;Initial Catalog=dentist;Integrated Security=True"
Dim dbCN As New SqlClient.SqlConnection(dbCS)
Try
dbCN.Open()
Dim cmd As New SqlClient.SqlCommand
With cmd
.Connection = dbCN
.CommandType = CommandType.Text
Dim param As SqlClient.SqlParameter = cmd.Parameters.Add("@datum", SqlDbType.DateTime)
Dim da As New Data.SqlClient.SqlDataAdapter
param.Value = kalendar.Value.Date
.CommandText = ("SELECt CONVERT(varchar, posjeti.datum_posjeta, 108) AS Vrijeme, pacijent.prezime, pacijent.ime, zahvati.naziv_zahvata, zahvati.trajanje FROM pacijent INNER JOIN posjeti ON pacijent.ID_pacijenta = posjeti.ID_pacijenta INNER Join zahvati ON posjeti.ID_zahvata = zahvati.ID_zahvata WHERE (posjeti.datum_posjeta IN @datum")
da.SelectCommand = cmd
da.Fill(DentistDataSet.DataTable1)
dg1.DataSource = da
End With
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
My code:
Private Sub kalendar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kalendar.ValueChanged
Const dbCS As String = "Data Source=GORAN;Initial Catalog=dentist;Integrated Security=True"
Dim dbCN As New SqlClient.SqlConnection(dbCS)
Try
dbCN.Open()
Dim cmd As New SqlClient.SqlCommand
With cmd
.Connection = dbCN
.CommandType = CommandType.Text
Dim param As SqlClient.SqlParameter = cmd.Parameters.Add("@datum", SqlDbType.DateTime)
Dim da As New Data.SqlClient.SqlDataAdapter
param.Value = kalendar.Value.Date
.CommandText = ("SELECt CONVERT(varchar, posjeti.datum_posjeta, 108) AS Vrijeme, pacijent.prezime, pacijent.ime, zahvati.naziv_zahvata, zahvati.trajanje FROM pacijent INNER JOIN posjeti ON pacijent.ID_pacijenta = posjeti.ID_pacijenta INNER Join zahvati ON posjeti.ID_zahvata = zahvati.ID_zahvata WHERE (posjeti.datum_posjeta IN @datum")
da.SelectCommand = cmd
da.Fill(DentistDataSet.DataTable1)
dg1.DataSource = da
End With
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub