Enforce SQL DISTINCT in VB.NET
Posted on 2007-10-08
I have a simple SQL query that is written and executed in VB.NET.
Dim strBrokerSQL As String = "SELECT DISTINCT autonumber, (rateMonth + '_'+ rateDay+ '_'+rateYear+ '_'+rateversion+ '_'+brok_code) As RateSheetName, risk_adj, sales_adj FROM tblRates where rateMonth = '" & rateMonth & "' and rateDay = '" & rateDay"
Query pulls data from database including duplicate rows, so DISTINCT is not playing its role. I am not sure why it does not work?
I could probably achieve the wanted result, by writing stored procedure at SQL side and just execute it from VB.NET, but I was wondwering if there is a way to force DISTINCT from VB.NET code.