✅ IndexOutOfRangeException when trying to set class properties to reader return values
12 Replies
This is supposed to create a new object with it's property values set to what the reader returns then later add the new objects with their respective values to a list which will be used in a for loop to itterate the property values and display information inside some paragraph elements and such. However despite the stored procedure working and returning the right results based on the city name it causes an exception to occur which is the attached image to this post. I tried doing exception handling as well but the exception message when printing to the debug console is simply just "ProductName" which is weird to say the least. The column names are written correctly but it still returns null no matter what, except when indexed, then the Name property gets the value of 916.
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
Oh well yeah I tried debugging it, hence why when I use an index for the column instead of the alias it gives me the weird value of 916 I got that from debugging the property being set to that but since I'm using the stored procedure alias it just gives a value of null and crashes due to me removing the exception handling logic. But do you need me to check the reader's values instead?
anyway here:
I put it anyway
crashed right after i stepped over the Name property being set to the reader return value
with the same exception
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
ok
I've fixed it
It was a privilege issue, there are some procedures that create separate databases for each city and my fellow practician here forgot to update the prodecure to give it rights to the newly created database. It couldn't access it the whole time.
I'll close the post down
thanks for the help eitherway
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
Use the /close command to mark a forum thread as answered
thanks again!
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
lmao