Here, in the below example, we are retrieving the data by using the string key names, nothing but the column names returned by the select clause. Note: The DataReader object increases the performance of the application as well as reduces the system overheads and the reason for this is, one row at a time is stored in memory.
In the below example, we are accessing the data from the SqlDataReader object by using the index number. Here, the index is starting from 0. So, you can retrieve the data from the data reader by either using the string key or the Integer index position. In the below example, once we execute the ExecuteReader method, then we close the connection and then we try to read the data from the data reader.
As the connection is closed, so it will give a runtime error. In the next article, I am going to discuss the ADO. Here, in this article, I try to explain the ADO. I would like to have your feedback. Please post your feedback, question, or comments about this SqlDataReader in C with Examples article.
Your email address will not be published. Skip to content. The content you requested has been removed. Ask a question. Quick access. Search related threads. Remove From My Forums. Answered by:. Archived Forums. I hope this page doesn't get reloaded more than once. Show 2 more comments.
Active Oldest Votes. Try to give the value to the command. I think this code might help you. AddWithValue " bid", bookid ; rdrcmd. Close ;. Improve this answer. Abdul Haseeb Abdul Haseeb 1 1 silver badge 8 8 bronze badges. Thanks for your help, but it still not working.
It is still the same. Any other suggestions? The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated. Master now my answer get edited, try this one.
I think this will solve your question — Abdul Haseeb. Add a comment. Perhaps your problem is because you use the same variables in different scopes. Don't skimp on the variables. Just define a new one with clear names. AddWithValue " st", qt ; updateCommand. AddWithValue " bid", bookid ; updateCommand. Alexander Petrov Alexander Petrov Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.
0コメント