So I'm starting to learn some vb.net, and I have the following mysql statement to get a distinct count for a column in one of my tables. It's been giving me fits with syntax errors, but pretty much everything I've read suggests what I have should be correct. Also, I took it into MySQL Workbench and it works fine, for whatever reason it just refuses to work in my code.
Dim sRetrieve As String
Dim numvals As OdbcDataReader
sRetrieve = "SELECT COUNT (DISTINCT defect_code) FROM daily_data WHERE MONTH(date)=" & select_month & " AND YEAR(date)=" & select_year
Dim query_exe As New Odbc.OdbcCommand(sRetrieve, cn)
numvals = query_exe.ExecuteReader()
I've been banging my head against this for awhile now, so any help telling me what's wrong with that mysql statement would be greatly appreciated.
Figured it out, the space between COUNT and the first ( was doing it. Such a hilariously small thing for it to have held me up for so long, but I guess that's how it goes. Thanks for the help, everybody.