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 2050
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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |