Ask a Question related to ASP.NET General, Design and Development.
-
VB Programmer #1
HELP: Custom DataReader Function - Tricky issue
I have a function that returns a datareader. The problem is that in the
function's FINALLY I close the datareader and set it to nothing. But,
BEFORE the Finally I "Return" the datareader (in the Try).
The problem is, by the time it's "returned" it says I already closed it. Any
ideas how I can overcome this? How can I clean up the objects nicely WHILE
returning it back to the caller????
Example:
Private Sub x
Dim dr as SqlDataReader
....
....
dr = GetDr(...) ' FAILS BECAUSE THE DATAREADER IS CLOSED BY NOW!
....
End Sub
Private Function GetDr(...) as SqlDataReader
Dim MyDataReader as SqlDataReader
Try
.....
....
Return MyDataReader
Catch
Finally
MyDataReader.Close
MyDataReader = Nothing
End Function
VB Programmer Guest
-
Custom tag <cfx_image> issue
I have a problem with the <cfx_image> custom tag, when resizing an image of type jpeg. The image becomes almost completely black. I will be glad... -
Custom Tag and thisTag.AssocAttribs issue
Hi all, What I am trying to do is very simple. I am building a couple of custom tags (we will call cf_ParentTag and cf_ChildTag). The parent tag... -
Need Custom DataReader Loop in User Control: inline vs. code-behind
I'm trying to evaluate the benefits of designing user controls completely inline vs. using a code-behind file. I already have a user control... -
Custom control viewstate (?) issue!
I've been struggling for a day and yet haven't found a solution to such a problem: I have, let's say, an apsx page, which contains a UserControl,... -
Custom Web Control Deployment Issue
I have a custom web control in which I have created a setup project in the same solution. In the setup project, I have created a custom folder in... -
Marina #2
Re: Custom DataReader Function - Tricky issue
You can't. That's why you don't want to be returning datareaders. Because
then you are relying on the client to close the datareader and the
underlying connection.
Use a datatable or dataset instead.
"VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
news:uiF0PTQYDHA.2620@TK2MSFTNGP09.phx.gbl...Any> I have a function that returns a datareader. The problem is that in the
> function's FINALLY I close the datareader and set it to nothing. But,
> BEFORE the Finally I "Return" the datareader (in the Try).
>
> The problem is, by the time it's "returned" it says I already closed it.WHILE> ideas how I can overcome this? How can I clean up the objects nicely> returning it back to the caller????
>
> Example:
>
> Private Sub x
> Dim dr as SqlDataReader
> ....
> ....
> dr = GetDr(...) ' FAILS BECAUSE THE DATAREADER IS CLOSED BY NOW!
> ....
> End Sub
>
> Private Function GetDr(...) as SqlDataReader
> Dim MyDataReader as SqlDataReader
> Try
> .....
> ....
> Return MyDataReader
> Catch
> Finally
> MyDataReader.Close
> MyDataReader = Nothing
> End Function
>
>
>
Marina Guest



Reply With Quote

