I have a funtion that works fine and dandy when called from anywhere in my
app. It will NOT work when called from inside the class in which it resides.
This is the function I'm calling: "getProductByID(productID)" from inside
another method in the same class. See below.
This line throws a null ref exception:
While dr.Read()
Thanks for any insight!
Public Sub deleteProduct(ByVal productID)
'Set up parameters
Dim arParms(0) As SqlParameter
arParms(0) = New SqlParameter("@productID",
SqlDbType.UniqueIdentifier)
arParms(0).Value = productID
'get the images to delete
Dim context As System.Web.HttpContext = System.Web.HttpContext.Current
Dim dr As SqlDataReader = getProductByID(productID)
Dim thumbImg As String
Dim fullImg As String
While dr.Read()
'delete thumb
fullImg = context.Application("webRoot") &
"vendorImages/" & dr.Item("galleryFolder").ToString & "/" &
dr.Item("imageFull").ToString
fullImg = context.Current.Server.MapPath(fullImg)
Dim thisImgFull As New System.IO.FileInfo(fullImg)
thisImgFull.Delete()
End While
.... omitted for brevity
End Sub 8 2010
Hi,
Try:
Dim dr As New SqlDataReader = getProductByID(productID)
Also make sure that productID actually holds what you want it to when you
pass it. Here:
Public Sub deleteProduct(ByVal productID)
You are not giving it a type, should it be an Integer? Good luck! Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com... I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it
resides. This is the function I'm calling: "getProductByID(productID)" from inside another method in the same class. See below.
This line throws a null ref exception: While dr.Read()
Thanks for any insight! Public Sub deleteProduct(ByVal productID)
'Set up parameters Dim arParms(0) As SqlParameter arParms(0) = New SqlParameter("@productID", SqlDbType.UniqueIdentifier) arParms(0).Value = productID
'get the images to delete Dim context As System.Web.HttpContext =
System.Web.HttpContext.Current
Dim dr As SqlDataReader = getProductByID(productID)
Dim thumbImg As String Dim fullImg As String
While dr.Read() 'delete thumb fullImg = context.Application("webRoot") & "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & dr.Item("imageFull").ToString fullImg = context.Current.Server.MapPath(fullImg) Dim thisImgFull As New System.IO.FileInfo(fullImg) thisImgFull.Delete() End While
... omitted for brevity
End Sub
HI Ken, thanks for the reply. productID is a uniqueidentifier and it's
definitely coming in, I've double checked that. I also tried your
suggestiond, but no go. :(
"Ken Dopierala Jr." wrote: Hi,
Try:
Dim dr As New SqlDataReader = getProductByID(productID)
Also make sure that productID actually holds what you want it to when you pass it. Here:
Public Sub deleteProduct(ByVal productID)
You are not giving it a type, should it be an Integer? Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message news:10**********************************@microsof t.com... I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it resides. This is the function I'm calling: "getProductByID(productID)" from inside another method in the same class. See below.
This line throws a null ref exception: While dr.Read()
Thanks for any insight! Public Sub deleteProduct(ByVal productID)
'Set up parameters Dim arParms(0) As SqlParameter arParms(0) = New SqlParameter("@productID", SqlDbType.UniqueIdentifier) arParms(0).Value = productID
'get the images to delete Dim context As System.Web.HttpContext =
System.Web.HttpContext.Current
Dim dr As SqlDataReader = getProductByID(productID)
Dim thumbImg As String Dim fullImg As String
While dr.Read() 'delete thumb fullImg = context.Application("webRoot") & "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & dr.Item("imageFull").ToString fullImg = context.Current.Server.MapPath(fullImg) Dim thisImgFull As New System.IO.FileInfo(fullImg) thisImgFull.Delete() End While
... omitted for brevity
End Sub
Hi,
The problem is that dr is Nothing which means that for some reason your
getProductByID() is returning nothing instead of a data reader. I would
step through the code and make sure that getProductByID() is passing back a
valid data reader when called from your delete function. Also make sure the
data reader isn't being closed or going out of scope before you pass it
back. Can you post your getProductByID() function code and also tell what
the relationship between that and the delete function are code wise? I mean
are they in the same module or different classes. We need to find out why
Nothing is return by getProductByID() when called from the delete function
and not from other code in your solution. Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.com... HI Ken, thanks for the reply. productID is a uniqueidentifier and it's definitely coming in, I've double checked that. I also tried your suggestiond, but no go. :( "Ken Dopierala Jr." wrote:
Hi,
Try:
Dim dr As New SqlDataReader = getProductByID(productID)
Also make sure that productID actually holds what you want it to when
you pass it. Here:
Public Sub deleteProduct(ByVal productID)
You are not giving it a type, should it be an Integer? Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message news:10**********************************@microsof t.com... I have a funtion that works fine and dandy when called from anywhere
in my app. It will NOT work when called from inside the class in which it resides. This is the function I'm calling: "getProductByID(productID)" from
inside another method in the same class. See below.
This line throws a null ref exception: While dr.Read()
Thanks for any insight! Public Sub deleteProduct(ByVal productID)
'Set up parameters Dim arParms(0) As SqlParameter arParms(0) = New SqlParameter("@productID", SqlDbType.UniqueIdentifier) arParms(0).Value = productID
'get the images to delete Dim context As System.Web.HttpContext =
System.Web.HttpContext.Current
Dim dr As SqlDataReader = getProductByID(productID)
Dim thumbImg As String Dim fullImg As String
While dr.Read() 'delete thumb fullImg = context.Application("webRoot") & "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & dr.Item("imageFull").ToString fullImg = context.Current.Server.MapPath(fullImg) Dim thisImgFull As New System.IO.FileInfo(fullImg) thisImgFull.Delete() End While
... omitted for brevity
End Sub
Here's the getProductByID function. And the two methods are in the same
class. It's definitely not returning a valid sqlDatareader, just don't know
why that is.
thanks.
Public Function getProductByID(ByVal productID) As SqlDataReader
'Set up parameters
Dim arParms(0) As SqlParameter
arParms(0) = New SqlParameter("@productID",
SqlDbType.UniqueIdentifier)
arParms(0).Value = productID
'insert the data
Dim dr As SqlDataReader = SqlHelper.ExecuteReader(connStr,
CommandType.StoredProcedure, "productByIDGet", arParms)
Return dr
End Function
"Ken Dopierala Jr." wrote: Hi,
The problem is that dr is Nothing which means that for some reason your getProductByID() is returning nothing instead of a data reader. I would step through the code and make sure that getProductByID() is passing back a valid data reader when called from your delete function. Also make sure the data reader isn't being closed or going out of scope before you pass it back. Can you post your getProductByID() function code and also tell what the relationship between that and the delete function are code wise? I mean are they in the same module or different classes. We need to find out why Nothing is return by getProductByID() when called from the delete function and not from other code in your solution. Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message news:86**********************************@microsof t.com... HI Ken, thanks for the reply. productID is a uniqueidentifier and it's definitely coming in, I've double checked that. I also tried your suggestiond, but no go. :( "Ken Dopierala Jr." wrote:
Hi,
Try:
Dim dr As New SqlDataReader = getProductByID(productID)
Also make sure that productID actually holds what you want it to when you pass it. Here:
Public Sub deleteProduct(ByVal productID)
You are not giving it a type, should it be an Integer? Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message news:10**********************************@microsof t.com... > I have a funtion that works fine and dandy when called from anywhere in my > app. It will NOT work when called from inside the class in which it resides. > > This is the function I'm calling: "getProductByID(productID)" from inside > another method in the same class. See below. > > This line throws a null ref exception: > While dr.Read() > > Thanks for any insight! > > > > Public Sub deleteProduct(ByVal productID) > > 'Set up parameters > Dim arParms(0) As SqlParameter > arParms(0) = New SqlParameter("@productID", > SqlDbType.UniqueIdentifier) > arParms(0).Value = productID > > 'get the images to delete > Dim context As System.Web.HttpContext = System.Web.HttpContext.Current > > > Dim dr As SqlDataReader = getProductByID(productID) > > Dim thumbImg As String > Dim fullImg As String > > While dr.Read() > 'delete thumb > fullImg = context.Application("webRoot") & > "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & > dr.Item("imageFull").ToString > fullImg = context.Current.Server.MapPath(fullImg) > Dim thisImgFull As New System.IO.FileInfo(fullImg) > thisImgFull.Delete() > End While > > > ... omitted for brevity > > > End Sub
I can' tell why it isn't working. You could put a breakpoint on the Return
dr line. Then call this code from where it works in your code and also from
where it doesn't. If dr is valid at the breakpoint for one call and Nothing
for another then the problem has to be at what you are passing in. Also you
might want to put the New keyword in your Dim dr As SqlDataReader = ....
line below. Good luck! Ken.
"bidllc" <bi****@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com... Here's the getProductByID function. And the two methods are in the same class. It's definitely not returning a valid sqlDatareader, just don't
know why that is.
thanks. Public Function getProductByID(ByVal productID) As SqlDataReader
'Set up parameters Dim arParms(0) As SqlParameter arParms(0) = New SqlParameter("@productID", SqlDbType.UniqueIdentifier) arParms(0).Value = productID 'insert the data Dim dr As SqlDataReader = SqlHelper.ExecuteReader(connStr, CommandType.StoredProcedure, "productByIDGet", arParms) Return dr
End Function
"Ken Dopierala Jr." wrote:
Hi,
The problem is that dr is Nothing which means that for some reason your getProductByID() is returning nothing instead of a data reader. I would step through the code and make sure that getProductByID() is passing
back a valid data reader when called from your delete function. Also make sure
the data reader isn't being closed or going out of scope before you pass it back. Can you post your getProductByID() function code and also tell
what the relationship between that and the delete function are code wise? I
mean are they in the same module or different classes. We need to find out
why Nothing is return by getProductByID() when called from the delete
function and not from other code in your solution. Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message news:86**********************************@microsof t.com... HI Ken, thanks for the reply. productID is a uniqueidentifier and
it's definitely coming in, I've double checked that. I also tried your suggestiond, but no go. :( "Ken Dopierala Jr." wrote:
> Hi, > > Try: > > Dim dr As New SqlDataReader = getProductByID(productID) > > Also make sure that productID actually holds what you want it to
when you > pass it. Here: > > Public Sub deleteProduct(ByVal productID) > > You are not giving it a type, should it be an Integer? Good luck!
Ken. > > -- > Ken Dopierala Jr. > For great ASP.Net web hosting try: > http://www.webhost4life.com/default.asp?refid=Spinlight > If you sign up under me and need help, email me. > > "bidllc" <bi****@discussions.microsoft.com> wrote in message > news:10**********************************@microsof t.com... > > I have a funtion that works fine and dandy when called from
anywhere in my > > app. It will NOT work when called from inside the class in which
it > resides. > > > > This is the function I'm calling: "getProductByID(productID)" from inside > > another method in the same class. See below. > > > > This line throws a null ref exception: > > While dr.Read() > > > > Thanks for any insight! > > > > > > > > Public Sub deleteProduct(ByVal productID) > > > > 'Set up parameters > > Dim arParms(0) As SqlParameter > > arParms(0) = New SqlParameter("@productID", > > SqlDbType.UniqueIdentifier) > > arParms(0).Value = productID > > > > 'get the images to delete > > Dim context As System.Web.HttpContext = > System.Web.HttpContext.Current > > > > > > Dim dr As SqlDataReader = getProductByID(productID) > > > > Dim thumbImg As String > > Dim fullImg As String > > > > While dr.Read() > > 'delete thumb > > fullImg = context.Application("webRoot") & > > "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & > > dr.Item("imageFull").ToString > > fullImg =
context.Current.Server.MapPath(fullImg) > > Dim thisImgFull As New
System.IO.FileInfo(fullImg) > > thisImgFull.Delete() > > End While > > > > > > ... omitted for brevity > > > > > > End Sub > > >
2 pennies - is connStr actually declared and initialised ? I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it resides.
This is the function I'm calling: "getProductByID(productID)" from inside another method in the same class. See below.
This line throws a null ref exception: While dr.Read()
Thanks for any insight! Public Sub deleteProduct(ByVal productID)
'Set up parameters Dim arParms(0) As SqlParameter arParms(0) = New SqlParameter("@productID", SqlDbType.UniqueIdentifier) arParms(0).Value = productID
'get the images to delete Dim context As System.Web.HttpContext = System.Web.HttpContext.Current
Dim dr As SqlDataReader = getProductByID(productID)
Dim thumbImg As String Dim fullImg As String
While dr.Read() 'delete thumb fullImg = context.Application("webRoot") & "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & dr.Item("imageFull").ToString fullImg = context.Current.Server.MapPath(fullImg) Dim thisImgFull As New System.IO.FileInfo(fullImg) thisImgFull.Delete() End While
.... omitted for brevity
End Su
User submitted from AEWNET ( http://www.aewnet.com/)
yup...
"Guest" wrote: 2 pennies - is connStr actually declared and initialised ?
I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it resides.
This is the function I'm calling: "getProductByID(productID)" from inside another method in the same class. See below.
This line throws a null ref exception: While dr.Read()
Thanks for any insight! Public Sub deleteProduct(ByVal productID)
'Set up parameters Dim arParms(0) As SqlParameter arParms(0) = New SqlParameter("@productID", SqlDbType.UniqueIdentifier) arParms(0).Value = productID
'get the images to delete Dim context As System.Web.HttpContext = System.Web.HttpContext.Current
Dim dr As SqlDataReader = getProductByID(productID)
Dim thumbImg As String Dim fullImg As String
While dr.Read() 'delete thumb fullImg = context.Application("webRoot") & "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & dr.Item("imageFull").ToString fullImg = context.Current.Server.MapPath(fullImg) Dim thisImgFull As New System.IO.FileInfo(fullImg) thisImgFull.Delete() End While
.... omitted for brevity
End Sub
User submitted from AEWNET (http://www.aewnet.com/)
I know, it's very frustrating. I'll keep poking around but I am just
completely stumped. THanks for trying!
"Ken Dopierala Jr." wrote: I can' tell why it isn't working. You could put a breakpoint on the Return dr line. Then call this code from where it works in your code and also from where it doesn't. If dr is valid at the breakpoint for one call and Nothing for another then the problem has to be at what you are passing in. Also you might want to put the New keyword in your Dim dr As SqlDataReader = .... line below. Good luck! Ken.
"bidllc" <bi****@discussions.microsoft.com> wrote in message news:32**********************************@microsof t.com... Here's the getProductByID function. And the two methods are in the same class. It's definitely not returning a valid sqlDatareader, just don't know why that is.
thanks. Public Function getProductByID(ByVal productID) As SqlDataReader
'Set up parameters Dim arParms(0) As SqlParameter arParms(0) = New SqlParameter("@productID", SqlDbType.UniqueIdentifier) arParms(0).Value = productID 'insert the data Dim dr As SqlDataReader = SqlHelper.ExecuteReader(connStr, CommandType.StoredProcedure, "productByIDGet", arParms) Return dr
End Function
"Ken Dopierala Jr." wrote:
Hi,
The problem is that dr is Nothing which means that for some reason your getProductByID() is returning nothing instead of a data reader. I would step through the code and make sure that getProductByID() is passing back a valid data reader when called from your delete function. Also make sure the data reader isn't being closed or going out of scope before you pass it back. Can you post your getProductByID() function code and also tell what the relationship between that and the delete function are code wise? I mean are they in the same module or different classes. We need to find out why Nothing is return by getProductByID() when called from the delete function and not from other code in your solution. Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me.
"bidllc" <bi****@discussions.microsoft.com> wrote in message news:86**********************************@microsof t.com... > HI Ken, thanks for the reply. productID is a uniqueidentifier and it's > definitely coming in, I've double checked that. I also tried your > suggestiond, but no go. :( > > > > "Ken Dopierala Jr." wrote: > > > Hi, > > > > Try: > > > > Dim dr As New SqlDataReader = getProductByID(productID) > > > > Also make sure that productID actually holds what you want it to when you > > pass it. Here: > > > > Public Sub deleteProduct(ByVal productID) > > > > You are not giving it a type, should it be an Integer? Good luck! Ken. > > > > -- > > Ken Dopierala Jr. > > For great ASP.Net web hosting try: > > http://www.webhost4life.com/default.asp?refid=Spinlight > > If you sign up under me and need help, email me. > > > > "bidllc" <bi****@discussions.microsoft.com> wrote in message > > news:10**********************************@microsof t.com... > > > I have a funtion that works fine and dandy when called from anywhere in my > > > app. It will NOT work when called from inside the class in which it > > resides. > > > > > > This is the function I'm calling: "getProductByID(productID)" from inside > > > another method in the same class. See below. > > > > > > This line throws a null ref exception: > > > While dr.Read() > > > > > > Thanks for any insight! > > > > > > > > > > > > Public Sub deleteProduct(ByVal productID) > > > > > > 'Set up parameters > > > Dim arParms(0) As SqlParameter > > > arParms(0) = New SqlParameter("@productID", > > > SqlDbType.UniqueIdentifier) > > > arParms(0).Value = productID > > > > > > 'get the images to delete > > > Dim context As System.Web.HttpContext = > > System.Web.HttpContext.Current > > > > > > > > > Dim dr As SqlDataReader = getProductByID(productID) > > > > > > Dim thumbImg As String > > > Dim fullImg As String > > > > > > While dr.Read() > > > 'delete thumb > > > fullImg = context.Application("webRoot") & > > > "vendorImages/" & dr.Item("galleryFolder").ToString & "/" & > > > dr.Item("imageFull").ToString > > > fullImg = context.Current.Server.MapPath(fullImg) > > > Dim thisImgFull As New System.IO.FileInfo(fullImg) > > > thisImgFull.Delete() > > > End While > > > > > > > > > ... omitted for brevity > > > > > > > > > End Sub > > > > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Krackers |
last post by:
How do you write a function which returns a reference to an array. I
can only get a function to return a copy of the array itself. I've had
a look at some other threads in this group an the return...
|
by: etwebbox |
last post by:
Hoping someone has some ideas on how to solve this issue:
I have a macro in excel which runs a query against an Access DB (it
actually calls a query inside of Access). The query is not bringing...
|
by: Jim P. |
last post by:
I'm having trouble returning an object from an AsyncCallback called inside a
threaded infinite loop.
I'm working on a Peer2Peer app that uses an AsyncCallback to rerieve the
data from the remote...
|
by: Cameron Frasnelly |
last post by:
I emulated the code from the .Net Framework help (Titled "Using Stored
Procedures with a Command") and I still receive and error...
Error Received = "Invalid attempt to read when no data is...
|
by: Charlie |
last post by:
Hi:
When returning an SqlDataReader from a database query, how do you get a
count of the number of records contained in the reader? There is no "Count"
property for reader object.
Thanks,...
|
by: rn5a |
last post by:
A SqlDataReader is populated with the records from a SQL Server 2005 DB
table. The records retrieved depends upon 2 conditions (the conditions
depend on what a user selects in an ASPX page). If...
|
by: RThaden |
last post by:
Hi together,
I am a bit clueless about the following problem:
In the following code excerpt
std::string getStr()
{
std::string bla="asdfsa";
|
by: Randy Smith |
last post by:
Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView control by
using the ObjectDataSource. This is our first OOP web application, and we
have no tables. Right now we are...
|
by: vinodkus |
last post by:
I M BEGINNER IN ASP
I WANT TO RETURN TOTAL RECORDS FROM A TABLE.
THERE ARE TWO FORMS CLASS1.ASP AND CLASS2.ASP
THROUGH FIRST FORM I JUST POST THE NAME OF TABLE
SO I M WRITING THE CODE OF...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |