I am trying to extract one integer from the database but am getting errors
My code in the controller is:
Dim SeqNumQuery = From a In db.RequestedServices
Where a.RequestedServiceId = id
Select a.StationId
Dim StationId As Integer = SeqNumQuery.ToString
And error is:
Range variable ‘StationId’ hides a variable in an enclosing block or a range variable previously defined in the query expression.
I think the issue is that your variable,
StationId, is being declared somewhere already within the same scope. Try changing to:But look into what the other variable is being used for. If you need it, use something other than
StationIdfor your variable name, for exampleRequestedServicesStationId.More information regarding this error:
Range variable hides a variable in an enclosing block or a range variable previously defined in the query expression.
On a side note, I don’t understand why you are using
.ToStringextension method. This won’t cause your script to throw an exception, however I would recommend changing this toCInt():