Sqldatareader getordinal null
Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services. Privacy policy. Thank you. Microsoft makes no warranties, express or implied, with respect to the information provided here. The following example demonstrates how to use the GetOrdinal method.
GetOrdinal performs a case-sensitive lookup first. Hi Arnebjarne, I can not post the Ticket ID, but if you are from Microsoft and you need it please send a email to zahirhas at hotmail dot com So far Microsoft not able to simulate or even we not able to simulate this problem, it happens occasionally and mostly during Business peak hours.
Thanks, Zahir. Monday, September 25, PM. I am experiencing the same error but under different circumstances. I am specifically trying to pull out a column by the name and I encounter an error.
I am catching the error and writing out all the field names in the datareader to a file. If anyone hears anything from Microsoft or finds a work around please let me know. Thanks -Jason. Friday, September 29, PM. I am experiencing the same problem when the server is heavily loaded. Thursday, October 5, PM. Few updates: Microsoft recommends not passing the SqlDataReader to another method and avoiding any static methods usage, they are not sure this is the root cause to this Exception.
The only thing that I am supicious of is that this wasn't an issue until recently. It never happened until a few weeks ago and now it happens all the time and nothing has changed in the code. Hi, I am also having the same problem in my application.
Many thanks Shameer. Wednesday, January 10, AM. I am having the exact same problem. I'm using ASP. Net 2. I have no idea what can be causing this issue, but I would like to get information about what can I do to solve it!
This is a critical error on the enterprise application, and it's not happening A LOT. Thanks, skullfire. Tuesday, January 16, PM. HI, I had the same problem but fortunately it is fixed now. Regards Shameer. Saturday, January 20, AM. Hi, Did you get a chance to contact Microsoft Support to resolve this, if so please let me know if you have any updates. Monday, January 22, PM. I believe this is ADO. NET related and nothing to do specifically with.
But please keep us updated if you find anything resolves this issue. Dear all We are getting this error too. Regards Phil. Monday, February 26, AM. OK - think we've cracked it.. Comments please. Tuesday, February 27, PM. I get the following call stack: at System. We are not using application blocks for data access. We are using: SqlConnection and SqlCommand My work around at this point is to make my own enums for the ordinals, but this is a pain and I can't understand why this problem is still going on.
Has MS responded? Should I create a new thread? Thanks Randy. Thursday, March 1, PM. Wednesday, March 14, PM. Has any solution been found on this matter, as I am experiencing the same exact problem. Saturday, March 31, PM. Just to let you guys know that I've solved the problem. Monday, April 2, PM. Tuesday, April 3, PM. Sorry that did not solve my problem. It started re-appearing after a couple of days. It seems that this happens in 2 cases : but it's so hard to be able to really pin point the problem 1.
When there's a peak on the server 2. When there's a connection timeout with the database. Anyone from Microsoft can help? Thursday, April 12, PM. That's my exact experience as well. You should use exception handling to ensure your connection is closed even if there is a timeout or other error. However, I seriously doubt that the connection is being returned to the pool while still actively running a query.
Not to mention that I timeout would immediately kill the query. Please, please first disable connection pooling and see if that resolves your issue. If it does and and we can get more to collaborate this then maybe someone from Microsoft will start to look into it. I have turned off connection pooling. Back in a few day to post my observations. We are experiencing this exact same problem very frequently lately. The error gets logged in our our event viewer and always identifies a column which is the first column expected from the DataReader.
This leads me to believe that the row is empty in the DataReader. However in reviewing the code we are using standard if dr. I never expected that using dr. NET 1. Lee wrote: I have turned off connection pooling. Friday, April 13, PM. And turning off connection pooling is a no-go for our site - given the amount of traffic we are supporting.
I've turned pooling off. It's been 3 days now, and I haven't had a single error. Saturday, April 14, AM.
I haven't had this error since I turned off connection pooling. Monday, April 16, AM. Typically, an out of range failure is because the object being refrenced is not populated with data. For example when your routine to fetch the DataReader fails to return any rows. Wednesday, April 18, PM. Thursday, April 19, AM. Still going. Tuesday, May 8, PM. In Event Viewer Warning appear messages like: System.
The only solution I found: - Wait a few minutes then everything return to work fine - Restart IIS Does someone know how to solve this problem? This post has been opened in Nov … Thanks, Emanuele.
Thursday, May 10, PM. StoredProcedure; sqlCmd. CreateParameter ; ContactUidParam. Input; ContactUidParam. ToString ; ContactUidParam. Int; sqlCmd. ToString ; this. CreateAttribute "uid" ; SiteElement. ToString ; SiteElement. CreateAttribute "name" ; SiteElement.
Message; this. Thanks, Emanuele. Friday, May 11, PM. I would add a connection close to your exception logic and see if that resolved your issue. Do you get any other errors before this error starts to happen? Maybe a timeout error? Emanuele wrote: Have you turned on your connection pool? Hi all, So I've read over this thread. It would be great if our friends in MS got on board and dealt with this issue - 2 years and counting is quite a long time Our setup: ASP.
This is a new issue that presented itself in the last few months. We migrated to ASP. Comprehensive web-based database application with up users login to the system on a daily basis. Data access layer provides our data access methods such as GetDataReader.
It manages the connections to the database, command objects, exception handling etc, and also includes type-safe reader methods. DataException are caught in the DAL and thrown up the application layers, adding appropriate information as required. The problem: This morning we received many error notifications all of which easily recognisable as a missing column in a data reader.
I tried logging into the system and could not - serious problem of down time for our customers. I opted for the former and it solved the problem, for now. The issue has occurred once before and that time, if I remember correctly, it resolved itself after a while. We cannot afford to let it "resolve itself". Example of error message: System. String Stacktrace: at System.
Read Comments We simply cannot turn off connection pooling - it would cause far greater problems given the size of our application. The problem may be related to load but given that today was just a normal day i. A number of people who posted suggested restartng IIS. If it happens again I may try that. I modified our code to trace extra exception details as follows: If reader. HasRows is true [Note: in our case this should always return true given that we already use reader.
Read which return true if records have been returned] Atttempt to read the column Catch the System. Trace out the properties FieldCount and HasRows of the reader object.
However, given that it has happened only twice in the last few months I don't expect the issue to occur any time soon again. Also note that there were no new deployments lately so the application state has not been modified in any way to cause these issues. There is also the problem in trying to resolve this issue as I cannot replicate it and so cannot be sure that any change I make has resolved it. So any change I make to the system will not be done lightly. Some of the other comments on this thread included: "Microsoft recommends not passing the SqlDataReader to another method and avoiding any static methods usage, they are not sure this is the root cause to this Exception.
Otherwise the object would have to be instantiated each and every time we want to do a data access. Please explain how the data reader could be receiving data for other tables? Any advice or comments are appreciated.
Cheers, Martin. Tuesday, May 15, PM. No posts in over 6 months, has anyone found a resolution to this problem? Monday, November 19, PM. Hi Andrew, We decided to refactor our data access code such that the SqlDataReader object is no longer being passed into the static reader methods.
Regards, Martin. Tuesday, November 20, AM. We are still running with connection pooling off without any issues. Tuesday, November 20, PM. Thanks for the replys to this old thread. Our problem occurs using. We are seeing this happen about once a week. When it happens it seems to be either caused by or causing a chain reaction where all the users start to loose their session.
We can't reproduce this error, we can't seem to pin point it to any specific place in our code or any specific error, we can't even say that this only happens under heavy load. The only thing that is common is it only happens on our prodcution servers and when it happens there are numerous SQLDataReader. Unfortunately, turning off connection pooling isn't really an option with the load that our servers can find themselves under.
Hi Andrew, First of all in response to other comments in this thread I can say that in our case turning of connection pooling is also not an option for us for the same reason. I read the following comment: "Microsoft recommends not passing the SqlDataReader to another method and avoiding any static methods usage, they are not sure this is the root cause to this Exception.
Hope this helps, Martin. Wednesday, November 21, AM. Hi Martin When the problem occurs, we have to fail over to our backup server. Monday, November 26, PM.
Hi Andrew, This suggests that the problem you are experiencing might be different. Good luck with it, Martin. Tuesday, November 27, AM. Hello, We experienced this problem for the first time today and a quick restart of the website seemed to get things running again I added a space to the end of the connection string which had two effects - it restarted the website and caused a new connection pool to start.
Thanks P. Tuesday, February 12, AM. Has anyone figured this out yet? I'm having the same issues. Stable code that's been running for over a year and about 2 weeks ago these problems started happening. I just turned connection pooling off but that in not an acceptable solution long term. Wednesday, March 19, PM. We had some static methods that were being used for our database calls. After opening up an issue with Microsoft they insisted that any calls to the database should not be inside of a static method.
After removing all static methods that had anything to do with the database, the problem has disappeared. I should note that the error messages we saw were not always related to the static methods.
However, we haven't had any reoccurrence in over a month. What makes something static vs non-static? Thursday, March 20, PM. Using the static modifier when declaring a method makes that method static.
What determines static vs non-static in vb. I've refactored all the code and removed all static methods. I am returning the connection string in a static method but it's just a string. And I'm still experiencing the issues.
I turned connection pooling off so hopefully that helps until we can figure out what is causing all this. Lee Murawski o2 wrote: Thanks. Code Snippet. Sunday, April 20, PM. Anyone have tried it? Friday, July 4, AM. Could somebody confirm that the hotfix works? The description doesn't really match the error everybody is facing here.
And please MS, could someone please pretty please join in. This topic has been lingering without a solution for far too long! In the mean time I'll be trying the following code: Code Snippet.
Thursday, July 10, PM. I haven't tried the hotfix yet, but it does seem likely that this hotfix will solve the problem. Tuesday, July 29, PM. This hotfix has been supposedly rolled into. As our servers are always under fairly heavy load all day, this error keeps popping up at the rate of to occurrences per day per server. Btw, we use nHibernate 2. Friday, January 30, PM.
We also having same issue in our production server. Anyone found the solution for it. Thursday, February 19, PM. A client of ours just reported encountering this error.
Our application is a windows application not a web application. We're using. The application has been running fine for over 4 months and this is the first time we see this error. Friday, February 20, AM. We are also experincing these errors. Any update to this other then disabling pooling? We have now implemented this and will see if the errors disappears.
We now that disabling pooling is very bad for performance, but we a re beginning to get desperate, as we have dealt with this for the last 5 weeks, encountering this error times a week. We are using Windows , Sql Server and. Monday, March 2, PM. Problem is fixed for me I did three steps and updated the application to live server before 15 days, still we dint get any errors in live website. We used to get aleast once in a day but now its fixed. Here is my three steps It was using try, catch and finally to close the connection.
Only these changes i did in my project. And errors gone. Please try this solution. Thanks, Anto Binish Kaspar. Saturday, March 7, PM. Hello everyone, I have read the topic thoroughly since I experience the same problem as described above. The situation is similar: I do an query to a stored procedure and sometimes get IndexOutOfRange exception.
It occurs rarely and only during peak hours. I was unable to reproduce the problem on my developer's environment. I found the reason why it fails sometimes. The problem is that returned resultset is invalid and has no relation to initial query. Consider this example: There is a database with 2 tables: one stores information about websites with a default domain name and another table contains additional domain names to each website.
I have a stored procedure which fetch website Id by domain name. I call the procedure using pure ado. StoredProcedure; command. ExecuteReader ; if reader. Monday, March 16, PM. Tuesday, March 17, PM. Thanks for the answer, Matt. I've read the article and seems it's telling about losing the data, but not about mixing it in different SqlCommands as it happens in my case. Moreover, I've just checked my live environment settings and found out that SP 2 for.
So, I believe it is not the reason. For now I have scheduled pool recycling on the web server, but it is a temporary solution and will affect our customers badly. Any other ideas? Wednesday, March 18, AM. Our pooling code is very complex, it has to pool and also be aware of System. Transaction state of threads, manage this with connections to SQL Server, perform transaction escalation when needed, etc Also, inside the ASP.
NET uses thread aborts to cancel operations. You can have a thread in the middle of fetching a resultset from a connection and ASP. NET decides to abort the thread mid-operation. We added code in. Along with this you can have code that is not thread safe using connections after they are disposed for example, this can cause side effects like phantom results. GetILGenerator ; gen. DeclareLocal typeSqlStatistics ; gen. Emit OpCodes.
Ldnull ; gen. StartTimer this. Statistics ; gen. Call, typeSqlDataReader. GetProperty "Statistics", instflags BindingFlags. GetProperty, null, typeSqlStatistics, Type. EmptyTypes, null. GetMethod ; gen. Call, typeSqlStatistics. DefineLabel ; gen. Ldfld, typeSqlDataReader. GetField ; gen. CheckMetaDataIsReady ; gen. InvokeMethod, null, Type. Newobj, typeFieldNameLookup.
Stfld, typeSqlDataReader. MarkLabel branchTarget ; gen. Call, typeFieldNameLookup. StopTimer statistics ; gen. If it's not null, we return it. Otherwise, we return the default value. Value - VS will complain and not even compile it. But I definitely like the idea of wrapping this up in an extension method - makes life a lot easier! I tried to use your approach and compare the output of reader. GetInt32 to DBNull. Show 2 more comments. ChangeType instead of casting? I would think that you'd want to know as quickly as possible if the schema structure has changed instead of pushing default values to other parts of your system.
GetSqlInt32 ord ; return t. If someone has maybe an idea with a functional trick or two speak up Here is what we use on SQLServer and it works like a charm GetFieldType Ordinal. Price Brattin Price Brattin 1. IsDBNull ordinal return null; return reader. Daniel Hilgarth Daniel Hilgarth k 39 39 gold badges silver badges bronze badges.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Podcast Making Agile work for data science.
0コメント