HI im new here and looking for some help.
Im creating a windows service that exports data from 2 access databases, Ive created a windows form app that works, but when i try to create a service, the following code throws an error.
"Index out of range exception. Index was outside the bounds of the array "
I have also tried using the sql with parameters like....
WHERE Channels.Measurand = @measureand1
'cmdSQL.Parameters.AddWithValue("@Measurand1", "Volume")
'cmdSQL.Parameters.AddWithValue("@Measurand2", "Energy")
I know the files exist and the path in the connection string is correct, and the sql should return me around 300 rows
Any help is greatly appreciated
Dim srcDB As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + srcPath + "\ForExport\controldata.mdb"
Dim srcDB2 As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + srcPath + "\ForExport\meterdata.mdb"
Dim connAccess As New System.Data.OleDb.OleDbConnection
connAccess.ConnectionString = srcDB
Dim cmdSQL As New Data.OleDb.OleDbCommand
Dim strCommand As String = "SELECT Sites.SiteName, Channels.ChannelName, Channels.ChannelNumber, Channels.MeasurementFactor, Channels.MeterID FROM Sites, Channels WHERE Sites.ID = Channels.SiteID AND (Channels.Measurand = 'Volume' OR channels.Measurand = 'Energy')"
cmdSQL.Connection = connAccess
cmdSQL.CommandType = CommandType.Text
cmdSQL.CommandText = strCommand
Dim dsMeters As New DataSet
Dim daMeters As New OleDb.OleDbDataAdapter(cmdSQL)
Try
connAccess.Open()
daMeters.Fill(dsMeters, "ControlData")
connAccess.Close()
If dsMeters.Tables("ControlData").Rows.Count > 0 Then
System.Diagnostics.EventLog.WriteEntry("maccy", "Control Data OK "(dsMeters.Tables("ControlData").Rows.Count.ToString), EventLogEntryType.Information)
End If
Catch ex As Exception
System.Diagnostics.EventLog.WriteEntry("maccy", "Exception: getControlData " + ex.ToString, EventLogEntryType.Error)
End Try