Private Sub btnRtvOutlook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRtvOutlook.Click
' *** Delete all records in databse, which has been uploaded today
Dim myConnection As New System.Data.SqlClient.SqlConnection(myConnString)
Dim myQuery As String = "DELETE FROM tblXIST_ESR_OPP WHERE DATEDIFF(day, UPLOAD_TIME, GETDATE()) = 0"
Dim myCommand As New System.Data.SqlClient.SqlCommand(myQuery, myConnection)
myCommand.Connection = myConnection
' *** INSERT TODAYS OUTLOOK INFORMATION INTO THE DATABASE
Dim qs As String
'This one works perfectly at returns the Unit_Revenue__c result being "26000"
'qs = "SELECT Id, Unit_Revenue__c FROM Equipment_Data__c"
'This one also works and returns the deal type perfectly being "Cash"
'qs = "SELECT Id, Deal_Type__c FROM Equipment_Data__c"
'This one also works, and return both field being "26000 - Cash"
'qs = "SELECT Id, Unit_Revenue__c, Deal_Type__c FROM Equipment_Data__c"
'This one doesn't work, it only returns "- - 14-06-2012 11:09:59"
qs = "SELECT Id, Unit_Revenue__c, Deal_Type__c, CreatedDate FROM Equipment_Data__c"
Dim qr As apex.QueryResult = binding.query(qs)
If (qr.size = 0) Then
For i As Integer = 1 To qr.records.GetUpperBound(0)
Dim equipment As apex.Equipment_Data__c = CType(qr.records(i), apex.Equipment_Data__c)
'*** HERE I NORMALLY HAVE A FUNCTION THAT RETURNS THE VALUES INTO A SQL DATABASE, BUT
'*** I HAVE CUT IT OUT TO REDUCE PLACES OF ERRORS AND ARE ONLY RETURNING VALUES IN MSGBOX
MsgBox(equipment.Unit_Revenue__c & " - " & equipment.Deal_Type__c & " - " & equipment.CreatedDate)