|
I get this error: "Invalid attempt to FieldCount when reader is closed." on the databind() method when the following code is run:
Private Sub loadProject()
Dim objDR As SqlDataReader
Dim objConn As New SqlConnection(strConn)
Dim objSQL As New SqlCommand("SELECT * FROM Projects ORDER BY Priority DESC, ProjectID DESC", objConn)
objConn.Open()
objDR = objSQL.ExecuteReader
grdDisplay.DataSource = objDR
grdDisplay.DataBind() <--Error occurs here
If grdDisplay.Items.Count = 0 Then
grdDisplay.Visible = False
lblMessage.Text = "No projects found."
Else
grdDisplay.Visible = True
End If
objDR.Close()
objConn.Close()
End Sub
This code is called directly from the Page_Load event on the first page after login so there are no prior database calls that could close the connection. When I step through the code in VS the autos window shows the objDR IsClosed property is FALSE at the time the databind() method is called.
This same code (different SQL strings) works fine everywhere else in the app. Also it has been working fine all along and just simply stopped working. The only change I made was moving the database and thus adjusting the connection string (which works fine elsewhere.
What am I missing?
Thank you in advance for any suggestions!
Peter
-- modified at 14:37 Monday 8th May, 2006
|
|
|
|
|
Try this.
Private Sub loadProject()
Dim objDR As SqlDataReader
Dim objConn As New SqlConnection(strConn)
Dim objSQL As New SqlCommand("SELECT * FROM Projects ORDER BY Priority DESC, ProjectID DESC", objConn)
objConn.Open()
objDR = objSQL.ExecuteReader
grdDisplay.DataSource = objDR
grdDisplay.DataBind() <--Error occurs here
objDR.Close()
objConn.Close()
If grdDisplay.Items.Count = 0 Then
grdDisplay.Visible = False
lblMessage.Text = "No projects found."
Else
grdDisplay.Visible = True
End If
End Sub
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Thanks for the suggestion - however I still get the same error. This error occurs on both my development laptop, and on my internal test server.
|
|
|
|
|
How is your grid set up? I bet you are attempting to bind to columnName not returned in your query. Remember the fieldnames are case sensitve. Also, try not using * but rather listing the fields.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Thanks! You forced me to review the datagrid setup and of course I realized that I have an embedded datagrid that lists project tasks, and of course it was throwing the error, not the parent datagrid().
Sometimes you cant see the forest through the trees.
|
|
|
|
|
I use MS Studio to coding the asp.net, i need to perform some action if the user close the web page, i try page_unload before but cannot function. So, may i know where i should put my code for the coding page, when the user close the page and some action fired?
|
|
|
|
|
The page unload is the event on the code behind not the client. You can't really run server code when the browser closes. You can however, run code in the global.asax for the Session_End event.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Well you can call some server-side code using AJAX in the onBeforeUnLoad
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
This is a difficult one. You can add a javascript function to the body (onunload). The only problem you have is that this function will fire before postback as well. You will have to pull some trick of setting a javascript variable that controls the function.
You won't be able to do server side processing, because the page will not do a request when you close it. Well I think so. If that is wrong, can someone please correct me.
TMF
|
|
|
|
|
Use Window.unload Event of the Javascript
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
Hi,
just write the following javascript function
function closeIt()
{
event.returnValue="closing";
}
and write the following in Html body
Let me know if you have any questions.
Thanks,
Bhasker P
|
|
|
|
|
Hi this is more a question about appearance than anything. I have a check box list which I want to divide up as follows. 3 Items followed by a heading followed by another 3 items heading and so on. But all the items are the same list. Can this be done? Thanks in advance
|
|
|
|
|
You need to be a little creative. I would suggest creating a user control formatted the way you want. Then pass the user control the heading and dataset (3 records). Use the loadcontrol option to dynamically add them to your page. Or have a dropdownlist that filters the checkbox.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
String.Format("{000:N}", maxNumberFound)
maxNumberFound is = 3
and I want it to display as "003".
anyone know how without string manipulation.
Thanks,
Nick
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
|
Yeah I used ToString to format it.
I tried deleting it, but could find the topic.
Thanks tho
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
Did you already resolve this?
If not, try this:
String.Format ("{0:D3}", maxNumberFound)
Jon Sagara
When I grow up, I'm changing my name to Joe Kickass!
My Site | My Blog | My Articles
-- modified at 13:07 Monday 8th May, 2006
|
|
|
|
|
actually yes.
Jon Sagara wrote: String.Format ("{0:D3}", maxNumberFound)
Unfortunately, that just returns "3.00" I used d5.
But the ToString has an override that I can say "000" and it will form correctly.
Thanks for helping tho.
Nick
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
Ista wrote: Unfortunately, that just returns "3.00" I used d5.
That's weird. Maybe it's a difference of UI cultures that causes that. On my system it returns "003".
Oh well. Glad you got it sorted.
Jon Sagara
When I grow up, I'm changing my name to Joe Kickass!
My Site | My Blog | My Articles
|
|
|
|
|
When I right click on the .aspx page , i see html code totally.I have used requiredfieldvalidations and regularexpression validation..Somehow i want to hide the content of this page when right clicked..Is there a way to secure the page content by hiding some field data..Plz help...
lehya reddy
|
|
|
|
|
google "javascript hide source"
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
This might help you[^].
You will still need to get rid of the browser menu so that the don't go to View / Page Source.
daniero
|
|
|
|
|
Hi
i have a paper that content of that is text. i scan it and now i want convert it to the MSword file can i do this work???????? my text is persian language and scaner can not do this work compilitly because their font is not complete. i want a software that can do this work.
can any body help me??????
|
|
|
|
|
Is there a control out there for purchase which offers predictive text functionality similar to Outlook's autocomplete feature when e-mailing?
To me, this is a non-web feature and my gut reaction is no even if it was available it would be horrible. But a client wants this functionality so I am just making sure its not out there for purchase.
I came across this: http://www.codeproject.com/aspnet/combobox.asp which wraps functionality from http://www.deadbeef.com/index.php/dhtml_combobox in a webcontrol. Its a dropdownlist with autocomplete, but not really predictive text like Outlook.
|
|
|
|
|
Dear All,
Now I am providing a solution to a web based(asp.net) application. Almost all the work completed. But the thing is that web application is working fine in my local machine. If i put that application into client's Developement server, the buttons(like submit, update) are not working on that server. If i click any button in that applcation on Dev, no event is fired. Nothing happened.
What is the solution for this? what are the steps should I do to wake up that buttons?
I need this ASAP........
Thanks,
Bhasker P
|
|
|
|