i'm trying to get the Max field where date = today using this code:
Dim todaydate = Format(Today.Date, "dd/MM/yyyy")
Dim sql1 As String = "Select max(snum) From tblbill where idate = #" & todaydate & "# "
Dim conn1 As SqlConnection = New SqlConnection(constr)
Dim cmd1 As SqlCommand = New SqlCommand(sql1, conn1)
conn1.Open()
Dim dr1 As SqlDataReader = cmd1.ExecuteReader
dr1.Read()
If IsDBNull(dr1(0)) Then
TextBox6.Text = 1
Else
TextBox6.Text = dr1(0) + 1
End If
dr1.Close()
cmd1.Dispose()
conn1.Close()
but when run the app i got this error: Incorrect syntax near '#'. may anyone help please!
#is the date delimiter for Access SQL, use single quotes for T-SQL (and perhaps a locale agnostic date format like yyyymmdd).Format(Today.Date, "dd/MM/yyyy")to return an injectable string?