asp and activeX DLL 
Author Message
 asp and activeX DLL

i'm new to programming so please pardon my igorance. if someone could help,
i would appreciate it.

i'm developing an activeX dll which runs on a webserver. and a website that
utilizes ASP to send requests to this dll. with one of my "requests" i get
the following error:

    Microsoft VBScript runtime error '800a000d'
    Type mismatch: 'Visit.Catalog.updateProduct'
    default.asp, line 30

to be specific, i only get this error if i don't fill in each and every
field of the form. if i leave a field blank, i get this error. the form is
designed to update a product database so i want it do be able to have blank
fields (meaning leave the current information in the database alone). for
example, if the price or cost of the product changes, i want to be able to
pull up the product on my active server page, change only the price/cost and
NOT the description or other data. can anyone tell me why this isn't
working?

that line contains the call to the dll. here are the relevant portions of
the webpage:

<!--at the top of the page i have the call-->

If Request("savenewproduct") <> "" Then

 Dim NewProductID
 NewProductID = Visit.Catalog.Addproduct(Request("mfr"), Request("name"), _
  Request("details"), Request("department"), _
  Request("price"), Request("cost"), _
  request("weight"), request("itemNumber"), request("size"), _
  Request("stock"), Request("imageurl"))
End IF

<!--in the body, i have the form-->

 <form action="<%=request("script_name")%>" method="post" id="form1"
name="form1">
 <center><table border="0" cellspacing="0" cellpadding="3">
 <tr><td colspan="3" align="center">Edit Product
Information<br><br></td></tr>
 <% dim product
  set product = visit.catalog.getproduct(request("id"))%>
 <tr><td><center><font size="+2"><b>Field</b></font></center></td>
 <td><center><font size="+2"><b>Current Value</b></font></center></td>
 <td><center><font size="+2"><b>New Value</b></font></center></td></tr>

 <td>Item Number:&nbsp;</td>
 <td><%Response.Write product("itemNumber")%></td>
 <td><input type="text" name="itemNumberUpdate"
value="<%=request("itemNumberUpdate")%>"></td></tr>

 <tr><td class="heading">Name:&nbsp;</td>
 <td><%Response.Write product("name")%></td>
 <td><input type="text" name="nameUpdate"
value="<%=request("nameUpdate")%>"></td></tr>

 <tr><td class="heading">Size:&nbsp;</td>
 <td><%Response.Write product("size")%></td>
 <td><input type="text" name="sizeUpdate"
value="<%=request("sizeUpdate")%>"></td></tr>

 <tr><td>Weight:&nbsp;</td>
 <td><%Response.Write product("weight")%></td>
 <td><input type="text" name="weightUpdate"
value="<%=request("weightUpdate")%>">
 </td></tr>

 <tr><td class="heading">Details:&nbsp;</td>
 <td><%Response.Write product("details")%></td>
 <td><textarea name="detailsUpdate" rows="10"
cols="40"><%=request("detailsUpdate")%></textarea>
 </td><tr>

 <tr><td class="heading">Price:&nbsp;</td>
 <td><%Response.Write product("price")%></td>
 <td><input type="text" name="priceUpdate"
value="<%=request("priceUpdate")%>" size="10">
 </td></tr>

 <tr><td class="heading">Cost:&nbsp;</td>
 <td><%Response.Write product("cost")%></td>
 <td><input type="text" name="costUpdate" value="<%=request("costUpdate")%>"
size="10">
 </td></tr>

 <tr><td class="heading">Opening Stock:&nbsp;</td>
 <td><%Response.Write product("stock")%></td>
 <td><input type="text" name="stockUpdate"
value="<%=request("stockUpdate")%>">
 </td></tr>

 <tr><td class="std">Image Name:&nbsp;</td>
 <td><%Response.Write product("imageName")%></td>
 <td><input type="text" name="imageurlUpdate"
value="<%=request("imageurlUpdate")%>">
 </td></tr>

 <tr><td colspan="3" align="center">
 <br><input type="submit" value="Save Changes" id="submit3" name="submit3">
 </td></tr>
 <input type="hidden" name="SaveProductChanges" value="1">
 </table></center>
 </form>

and finally, here is the dll code:

Public Function UpdateProduct(ByVal id As Long, Optional ByVal name As
String, _
    Optional ByVal details As String, Optional ByVal price As Double, _
    Optional ByVal cost As Double, Optional ByVal weight As Long, _
    Optional ByVal itemNumber As String, Optional ByVal size As String, _
    Optional ByVal stock As Long, Optional ByVal imageName As String) As
Long

    Dim UpdateQuery As New Recordset
    UpdateQuery.Open "select * from products where productid=" & id, _
        m_utility.DB.DB, adOpenKeyset, adLockOptimistic
    If name <> "" Then UpdateQuery("name") = name
    If details <> "" Then UpdateQuery("details") = details
    If price <> 0 Then UpdateQuery("price") = price
    If cost <> 0 Then UpdateQuery("cost") = cost
    If weight <> 0 Then UpdateQuery("weight") = weight
    If itemNumber <> "" Then UpdateQuery("itemNumber") = itemNumber
    If size <> "" Then UpdateQuery("size") = size
    If stock <> 0 Then UpdateQuery("stock") = stock
    UpdateQuery.Update
    UpdateQuery.Close
    Set UpdateQuery = Nothing
End Function



Mon, 27 Oct 2003 01:28:53 GMT  
 asp and activeX DLL
Hi,

What you need to do is check each value entered and assign each value to a
variable. If the value is blank then you need to assign an empty string to
that variable.

For example
dim strMFR

if isnull(request("mfr")) then
 strMfr = ""
else
 strMfr=request("mfr")
end if

Then, when you call the AddProduct Method of the Visit.Catalog object, pass
in the variable.

Try this and it may work.

Glenn



Quote:
> i'm new to programming so please pardon my igorance. if someone could
help,
> i would appreciate it.

> i'm developing an activeX dll which runs on a webserver. and a website
that
> utilizes ASP to send requests to this dll. with one of my "requests" i get
> the following error:

>     Microsoft VBScript runtime error '800a000d'
>     Type mismatch: 'Visit.Catalog.updateProduct'
>     default.asp, line 30

> to be specific, i only get this error if i don't fill in each and every
> field of the form. if i leave a field blank, i get this error. the form is
> designed to update a product database so i want it do be able to have
blank
> fields (meaning leave the current information in the database alone). for
> example, if the price or cost of the product changes, i want to be able to
> pull up the product on my active server page, change only the price/cost
and
> NOT the description or other data. can anyone tell me why this isn't
> working?

> that line contains the call to the dll. here are the relevant portions of
> the webpage:

> <!--at the top of the page i have the call-->

> If Request("savenewproduct") <> "" Then

>  Dim NewProductID
>  NewProductID = Visit.Catalog.Addproduct(Request("mfr"), Request("name"),
_
>   Request("details"), Request("department"), _
>   Request("price"), Request("cost"), _
>   request("weight"), request("itemNumber"), request("size"), _
>   Request("stock"), Request("imageurl"))
> End IF

> <!--in the body, i have the form-->

>  <form action="<%=request("script_name")%>" method="post" id="form1"
> name="form1">
>  <center><table border="0" cellspacing="0" cellpadding="3">
>  <tr><td colspan="3" align="center">Edit Product
> Information<br><br></td></tr>
>  <% dim product
>   set product = visit.catalog.getproduct(request("id"))%>
>  <tr><td><center><font size="+2"><b>Field</b></font></center></td>
>  <td><center><font size="+2"><b>Current Value</b></font></center></td>
>  <td><center><font size="+2"><b>New Value</b></font></center></td></tr>

>  <td>Item Number:&nbsp;</td>
>  <td><%Response.Write product("itemNumber")%></td>
>  <td><input type="text" name="itemNumberUpdate"
> value="<%=request("itemNumberUpdate")%>"></td></tr>

>  <tr><td class="heading">Name:&nbsp;</td>
>  <td><%Response.Write product("name")%></td>
>  <td><input type="text" name="nameUpdate"
> value="<%=request("nameUpdate")%>"></td></tr>

>  <tr><td class="heading">Size:&nbsp;</td>
>  <td><%Response.Write product("size")%></td>
>  <td><input type="text" name="sizeUpdate"
> value="<%=request("sizeUpdate")%>"></td></tr>

>  <tr><td>Weight:&nbsp;</td>
>  <td><%Response.Write product("weight")%></td>
>  <td><input type="text" name="weightUpdate"
> value="<%=request("weightUpdate")%>">
>  </td></tr>

>  <tr><td class="heading">Details:&nbsp;</td>
>  <td><%Response.Write product("details")%></td>
>  <td><textarea name="detailsUpdate" rows="10"
> cols="40"><%=request("detailsUpdate")%></textarea>
>  </td><tr>

>  <tr><td class="heading">Price:&nbsp;</td>
>  <td><%Response.Write product("price")%></td>
>  <td><input type="text" name="priceUpdate"
> value="<%=request("priceUpdate")%>" size="10">
>  </td></tr>

>  <tr><td class="heading">Cost:&nbsp;</td>
>  <td><%Response.Write product("cost")%></td>
>  <td><input type="text" name="costUpdate"

value="<%=request("costUpdate")%>"

- Show quoted text -

Quote:
> size="10">
>  </td></tr>

>  <tr><td class="heading">Opening Stock:&nbsp;</td>
>  <td><%Response.Write product("stock")%></td>
>  <td><input type="text" name="stockUpdate"
> value="<%=request("stockUpdate")%>">
>  </td></tr>

>  <tr><td class="std">Image Name:&nbsp;</td>
>  <td><%Response.Write product("imageName")%></td>
>  <td><input type="text" name="imageurlUpdate"
> value="<%=request("imageurlUpdate")%>">
>  </td></tr>

>  <tr><td colspan="3" align="center">
>  <br><input type="submit" value="Save Changes" id="submit3"
name="submit3">
>  </td></tr>
>  <input type="hidden" name="SaveProductChanges" value="1">
>  </table></center>
>  </form>

> and finally, here is the dll code:

> Public Function UpdateProduct(ByVal id As Long, Optional ByVal name As
> String, _
>     Optional ByVal details As String, Optional ByVal price As Double, _
>     Optional ByVal cost As Double, Optional ByVal weight As Long, _
>     Optional ByVal itemNumber As String, Optional ByVal size As String, _
>     Optional ByVal stock As Long, Optional ByVal imageName As String) As
> Long

>     Dim UpdateQuery As New Recordset
>     UpdateQuery.Open "select * from products where productid=" & id, _
>         m_utility.DB.DB, adOpenKeyset, adLockOptimistic
>     If name <> "" Then UpdateQuery("name") = name
>     If details <> "" Then UpdateQuery("details") = details
>     If price <> 0 Then UpdateQuery("price") = price
>     If cost <> 0 Then UpdateQuery("cost") = cost
>     If weight <> 0 Then UpdateQuery("weight") = weight
>     If itemNumber <> "" Then UpdateQuery("itemNumber") = itemNumber
>     If size <> "" Then UpdateQuery("size") = size
>     If stock <> 0 Then UpdateQuery("stock") = stock
>     UpdateQuery.Update
>     UpdateQuery.Close
>     Set UpdateQuery = Nothing
> End Function



Tue, 28 Oct 2003 00:36:58 GMT  
 asp and activeX DLL
boy, i tried what you said and a hundred variations. 12 hours later, i still
didn't have a solution. finally, i started trying to work with the data
types (constants).

how do i change the datatypes for my variables in ASP?

i tried the function CDbl(image) but it gave me an error. Then i tried
telling it that if it was an empty string it was vbNull:

    if request("imageurl") <> "" then
      addImage = request("imageUrl")
     else
      addImage = vbNull
 end if

this seemed to work except that it filled the database with 1s for all the
empty fields.

being new and stupid, i even tried to declare it like i would in VB with:

dim image as long

but of course it didn't like that either.

perhaps the empty string is being passed in as the wrong datatype and that
is why i am getting the error?

what do you think?

ladorna

it appears that the default data type was vbEmpty.


Quote:
> i'm new to programming so please pardon my igorance. if someone could
help,
> i would appreciate it.

> i'm developing an activeX dll which runs on a webserver. and a website
that
> utilizes ASP to send requests to this dll. with one of my "requests" i get
> the following error:

>     Microsoft VBScript runtime error '800a000d'
>     Type mismatch: 'Visit.Catalog.updateProduct'
>     default.asp, line 30

> to be specific, i only get this error if i don't fill in each and every
> field of the form. if i leave a field blank, i get this error. the form is
> designed to update a product database so i want it do be able to have
blank
> fields (meaning leave the current information in the database alone). for
> example, if the price or cost of the product changes, i want to be able to
> pull up the product on my active server page, change only the price/cost
and
> NOT the description or other data. can anyone tell me why this isn't
> working?

> that line contains the call to the dll. here are the relevant portions of
> the webpage:

> <!--at the top of the page i have the call-->

> If Request("savenewproduct") <> "" Then

>  Dim NewProductID
>  NewProductID = Visit.Catalog.Addproduct(Request("mfr"), Request("name"),
_
>   Request("details"), Request("department"), _
>   Request("price"), Request("cost"), _
>   request("weight"), request("itemNumber"), request("size"), _
>   Request("stock"), Request("imageurl"))
> End IF

> <!--in the body, i have the form-->

>  <form action="<%=request("script_name")%>" method="post" id="form1"
> name="form1">
>  <center><table border="0" cellspacing="0" cellpadding="3">
>  <tr><td colspan="3" align="center">Edit Product
> Information<br><br></td></tr>
>  <% dim product
>   set product = visit.catalog.getproduct(request("id"))%>
>  <tr><td><center><font size="+2"><b>Field</b></font></center></td>
>  <td><center><font size="+2"><b>Current Value</b></font></center></td>
>  <td><center><font size="+2"><b>New Value</b></font></center></td></tr>

>  <td>Item Number:&nbsp;</td>
>  <td><%Response.Write product("itemNumber")%></td>
>  <td><input type="text" name="itemNumberUpdate"
> value="<%=request("itemNumberUpdate")%>"></td></tr>

>  <tr><td class="heading">Name:&nbsp;</td>
>  <td><%Response.Write product("name")%></td>
>  <td><input type="text" name="nameUpdate"
> value="<%=request("nameUpdate")%>"></td></tr>

>  <tr><td class="heading">Size:&nbsp;</td>
>  <td><%Response.Write product("size")%></td>
>  <td><input type="text" name="sizeUpdate"
> value="<%=request("sizeUpdate")%>"></td></tr>

>  <tr><td>Weight:&nbsp;</td>
>  <td><%Response.Write product("weight")%></td>
>  <td><input type="text" name="weightUpdate"
> value="<%=request("weightUpdate")%>">
>  </td></tr>

>  <tr><td class="heading">Details:&nbsp;</td>
>  <td><%Response.Write product("details")%></td>
>  <td><textarea name="detailsUpdate" rows="10"
> cols="40"><%=request("detailsUpdate")%></textarea>
>  </td><tr>

>  <tr><td class="heading">Price:&nbsp;</td>
>  <td><%Response.Write product("price")%></td>
>  <td><input type="text" name="priceUpdate"
> value="<%=request("priceUpdate")%>" size="10">
>  </td></tr>

>  <tr><td class="heading">Cost:&nbsp;</td>
>  <td><%Response.Write product("cost")%></td>
>  <td><input type="text" name="costUpdate"

value="<%=request("costUpdate")%>"

- Show quoted text -

Quote:
> size="10">
>  </td></tr>

>  <tr><td class="heading">Opening Stock:&nbsp;</td>
>  <td><%Response.Write product("stock")%></td>
>  <td><input type="text" name="stockUpdate"
> value="<%=request("stockUpdate")%>">
>  </td></tr>

>  <tr><td class="std">Image Name:&nbsp;</td>
>  <td><%Response.Write product("imageName")%></td>
>  <td><input type="text" name="imageurlUpdate"
> value="<%=request("imageurlUpdate")%>">
>  </td></tr>

>  <tr><td colspan="3" align="center">
>  <br><input type="submit" value="Save Changes" id="submit3"
name="submit3">
>  </td></tr>
>  <input type="hidden" name="SaveProductChanges" value="1">
>  </table></center>
>  </form>

> and finally, here is the dll code:

> Public Function UpdateProduct(ByVal id As Long, Optional ByVal name As
> String, _
>     Optional ByVal details As String, Optional ByVal price As Double, _
>     Optional ByVal cost As Double, Optional ByVal weight As Long, _
>     Optional ByVal itemNumber As String, Optional ByVal size As String, _
>     Optional ByVal stock As Long, Optional ByVal imageName As String) As
> Long

>     Dim UpdateQuery As New Recordset
>     UpdateQuery.Open "select * from products where productid=" & id, _
>         m_utility.DB.DB, adOpenKeyset, adLockOptimistic
>     If name <> "" Then UpdateQuery("name") = name
>     If details <> "" Then UpdateQuery("details") = details
>     If price <> 0 Then UpdateQuery("price") = price
>     If cost <> 0 Then UpdateQuery("cost") = cost
>     If weight <> 0 Then UpdateQuery("weight") = weight
>     If itemNumber <> "" Then UpdateQuery("itemNumber") = itemNumber
>     If size <> "" Then UpdateQuery("size") = size
>     If stock <> 0 Then UpdateQuery("stock") = stock
>     UpdateQuery.Update
>     UpdateQuery.Close
>     Set UpdateQuery = Nothing
> End Function



Tue, 28 Oct 2003 12:57:24 GMT  
 asp and activeX DLL
Have you checked the database field to see if it requires a value?  It could
be that the database is throwing the error and is bubbling through the DLL.
You need to look at the database in design mode and there should be a
property that allows you to enter null values.  Make sure that this is
checked for each field that can contain a null value.

Your code should work except you cannot use vbNull in the way that you have.
vbNull is an enumerated datatype and has a value of 1.  This is why 1 was
appearing in the database.  Try using the following after you have changed
the database to accept null values:

     if request("imageurl") <> "" then
       addImage = request("imageUrl")
     else
       addImage = " "
     end if

In ASP all variables are declared as variants.  However, if you are using an
object variable you need to use the "Set" keyword when you instantiate it.
For example, if objImage is declared in the declarations part of the ASP.
(Dim objImage), then you need to use the following (for example):

Set objImage = getImage("image")

Good luck.

By the way, a great book to read, if you haven't already, is "Beginning
E-Commerce" by Matther Reynolds (Wrox Press ISBN=1861003986)  This will walk
you through building an on-line commercial presence using ASP and VB.

Glenn



Quote:
> boy, i tried what you said and a hundred variations. 12 hours later, i
still
> didn't have a solution. finally, i started trying to work with the data
> types (constants).

> how do i change the datatypes for my variables in ASP?

> i tried the function CDbl(image) but it gave me an error. Then i tried
> telling it that if it was an empty string it was vbNull:

>     if request("imageurl") <> "" then
>       addImage = request("imageUrl")
>      else
>       addImage = vbNull
>  end if

> this seemed to work except that it filled the database with 1s for all the
> empty fields.

> being new and stupid, i even tried to declare it like i would in VB with:

> dim image as long

> but of course it didn't like that either.

> perhaps the empty string is being passed in as the wrong datatype and that
> is why i am getting the error?

> what do you think?

> ladorna

> it appears that the default data type was vbEmpty.


> > i'm new to programming so please pardon my igorance. if someone could
> help,
> > i would appreciate it.

> > i'm developing an activeX dll which runs on a webserver. and a website
> that
> > utilizes ASP to send requests to this dll. with one of my "requests" i
get
> > the following error:

> >     Microsoft VBScript runtime error '800a000d'
> >     Type mismatch: 'Visit.Catalog.updateProduct'
> >     default.asp, line 30

> > to be specific, i only get this error if i don't fill in each and every
> > field of the form. if i leave a field blank, i get this error. the form
is
> > designed to update a product database so i want it do be able to have
> blank
> > fields (meaning leave the current information in the database alone).
for
> > example, if the price or cost of the product changes, i want to be able
to
> > pull up the product on my active server page, change only the price/cost
> and
> > NOT the description or other data. can anyone tell me why this isn't
> > working?

> > that line contains the call to the dll. here are the relevant portions
of
> > the webpage:

> > <!--at the top of the page i have the call-->

> > If Request("savenewproduct") <> "" Then

> >  Dim NewProductID
> >  NewProductID = Visit.Catalog.Addproduct(Request("mfr"),
Request("name"),
> _
> >   Request("details"), Request("department"), _
> >   Request("price"), Request("cost"), _
> >   request("weight"), request("itemNumber"), request("size"), _
> >   Request("stock"), Request("imageurl"))
> > End IF

> > <!--in the body, i have the form-->

> >  <form action="<%=request("script_name")%>" method="post" id="form1"
> > name="form1">
> >  <center><table border="0" cellspacing="0" cellpadding="3">
> >  <tr><td colspan="3" align="center">Edit Product
> > Information<br><br></td></tr>
> >  <% dim product
> >   set product = visit.catalog.getproduct(request("id"))%>
> >  <tr><td><center><font size="+2"><b>Field</b></font></center></td>
> >  <td><center><font size="+2"><b>Current Value</b></font></center></td>
> >  <td><center><font size="+2"><b>New Value</b></font></center></td></tr>

> >  <td>Item Number:&nbsp;</td>
> >  <td><%Response.Write product("itemNumber")%></td>
> >  <td><input type="text" name="itemNumberUpdate"
> > value="<%=request("itemNumberUpdate")%>"></td></tr>

> >  <tr><td class="heading">Name:&nbsp;</td>
> >  <td><%Response.Write product("name")%></td>
> >  <td><input type="text" name="nameUpdate"
> > value="<%=request("nameUpdate")%>"></td></tr>

> >  <tr><td class="heading">Size:&nbsp;</td>
> >  <td><%Response.Write product("size")%></td>
> >  <td><input type="text" name="sizeUpdate"
> > value="<%=request("sizeUpdate")%>"></td></tr>

> >  <tr><td>Weight:&nbsp;</td>
> >  <td><%Response.Write product("weight")%></td>
> >  <td><input type="text" name="weightUpdate"
> > value="<%=request("weightUpdate")%>">
> >  </td></tr>

> >  <tr><td class="heading">Details:&nbsp;</td>
> >  <td><%Response.Write product("details")%></td>
> >  <td><textarea name="detailsUpdate" rows="10"
> > cols="40"><%=request("detailsUpdate")%></textarea>
> >  </td><tr>

> >  <tr><td class="heading">Price:&nbsp;</td>
> >  <td><%Response.Write product("price")%></td>
> >  <td><input type="text" name="priceUpdate"
> > value="<%=request("priceUpdate")%>" size="10">
> >  </td></tr>

> >  <tr><td class="heading">Cost:&nbsp;</td>
> >  <td><%Response.Write product("cost")%></td>
> >  <td><input type="text" name="costUpdate"
> value="<%=request("costUpdate")%>"
> > size="10">
> >  </td></tr>

> >  <tr><td class="heading">Opening Stock:&nbsp;</td>
> >  <td><%Response.Write product("stock")%></td>
> >  <td><input type="text" name="stockUpdate"
> > value="<%=request("stockUpdate")%>">
> >  </td></tr>

> >  <tr><td class="std">Image Name:&nbsp;</td>
> >  <td><%Response.Write product("imageName")%></td>
> >  <td><input type="text" name="imageurlUpdate"
> > value="<%=request("imageurlUpdate")%>">
> >  </td></tr>

> >  <tr><td colspan="3" align="center">
> >  <br><input type="submit" value="Save Changes" id="submit3"
> name="submit3">
> >  </td></tr>
> >  <input type="hidden" name="SaveProductChanges" value="1">
> >  </table></center>
> >  </form>

> > and finally, here is the dll code:

> > Public Function UpdateProduct(ByVal id As Long, Optional ByVal name As
> > String, _
> >     Optional ByVal details As String, Optional ByVal price As Double, _
> >     Optional ByVal cost As Double, Optional ByVal weight As Long, _
> >     Optional ByVal itemNumber As String, Optional ByVal size As String,
_
> >     Optional ByVal stock As Long, Optional ByVal imageName As String) As
> > Long

> >     Dim UpdateQuery As New Recordset
> >     UpdateQuery.Open "select * from products where productid=" & id, _
> >         m_utility.DB.DB, adOpenKeyset, adLockOptimistic
> >     If name <> "" Then UpdateQuery("name") = name
> >     If details <> "" Then UpdateQuery("details") = details
> >     If price <> 0 Then UpdateQuery("price") = price
> >     If cost <> 0 Then UpdateQuery("cost") = cost
> >     If weight <> 0 Then UpdateQuery("weight") = weight
> >     If itemNumber <> "" Then UpdateQuery("itemNumber") = itemNumber
> >     If size <> "" Then UpdateQuery("size") = size
> >     If stock <> 0 Then UpdateQuery("stock") = stock
> >     UpdateQuery.Update
> >     UpdateQuery.Close
> >     Set UpdateQuery = Nothing
> > End Function



Tue, 28 Oct 2003 15:59:41 GMT  
 asp and activeX DLL
If the properties in the DLL are String, and Not Variant, or Numeric, etc
then you need to Cast the variable to the string there is no way to do this
in ASP, so I always just append a "" to the end of all my properties in the
APS page ie:
    Request("Department") & ""

Give that a try and see if it works.

Good luck
Lance



i'm new to programming so please pardon my igorance. if someone could help,
i would appreciate it.

i'm developing an activeX dll which runs on a webserver. and a website that
utilizes ASP to send requests to this dll. with one of my "requests" i get
the following error:

    Microsoft VBScript runtime error '800a000d'
    Type mismatch: 'Visit.Catalog.updateProduct'
    default.asp, line 30

to be specific, i only get this error if i don't fill in each and every
field of the form. if i leave a field blank, i get this error. the form is
designed to update a product database so i want it do be able to have blank
fields (meaning leave the current information in the database alone). for
example, if the price or cost of the product changes, i want to be able to
pull up the product on my active server page, change only the price/cost and
NOT the description or other data. can anyone tell me why this isn't
working?

that line contains the call to the dll. here are the relevant portions of
the webpage:

<!--at the top of the page i have the call-->

If Request("savenewproduct") <> "" Then

 Dim NewProductID
 NewProductID = Visit.Catalog.Addproduct(Request("mfr"), Request("name"), _
  Request("details"), Request("department"), _
  Request("price"), Request("cost"), _
  request("weight"), request("itemNumber"), request("size"), _
  Request("stock"), Request("imageurl"))
End IF

<!--in the body, i have the form-->

 <form action="<%=request("script_name")%>" method="post" id="form1"
name="form1">
 <center><table border="0" cellspacing="0" cellpadding="3">
 <tr><td colspan="3" align="center">Edit Product
Information<br><br></td></tr>
 <% dim product
  set product = visit.catalog.getproduct(request("id"))%>
 <tr><td><center><font size="+2"><b>Field</b></font></center></td>
 <td><center><font size="+2"><b>Current Value</b></font></center></td>
 <td><center><font size="+2"><b>New Value</b></font></center></td></tr>

 <td>Item Number:?</td>
 <td><%Response.Write product("itemNumber")%></td>
 <td><input type="text" name="itemNumberUpdate"
value="<%=request("itemNumberUpdate")%>"></td></tr>

 <tr><td class="heading">Name:?</td>
 <td><%Response.Write product("name")%></td>
 <td><input type="text" name="nameUpdate"
value="<%=request("nameUpdate")%>"></td></tr>

 <tr><td class="heading">Size:?</td>
 <td><%Response.Write product("size")%></td>
 <td><input type="text" name="sizeUpdate"
value="<%=request("sizeUpdate")%>"></td></tr>

 <tr><td>Weight:?</td>
 <td><%Response.Write product("weight")%></td>
 <td><input type="text" name="weightUpdate"
value="<%=request("weightUpdate")%>">
 </td></tr>

 <tr><td class="heading">Details:?</td>
 <td><%Response.Write product("details")%></td>
 <td><textarea name="detailsUpdate" rows="10"
cols="40"><%=request("detailsUpdate")%></textarea>
 </td><tr>

 <tr><td class="heading">Price:?</td>
 <td><%Response.Write product("price")%></td>
 <td><input type="text" name="priceUpdate"
value="<%=request("priceUpdate")%>" size="10">
 </td></tr>

 <tr><td class="heading">Cost:?</td>
 <td><%Response.Write product("cost")%></td>
 <td><input type="text" name="costUpdate" value="<%=request("costUpdate")%>"
size="10">
 </td></tr>

 <tr><td class="heading">Opening Stock:?</td>
 <td><%Response.Write product("stock")%></td>
 <td><input type="text" name="stockUpdate"
value="<%=request("stockUpdate")%>">
 </td></tr>

 <tr><td class="std">Image Name:?</td>
 <td><%Response.Write product("imageName")%></td>
 <td><input type="text" name="imageurlUpdate"
value="<%=request("imageurlUpdate")%>">
 </td></tr>

 <tr><td colspan="3" align="center">
 <br><input type="submit" value="Save Changes" id="submit3" name="submit3">
 </td></tr>
 <input type="hidden" name="SaveProductChanges" value="1">
 </table></center>
 </form>

and finally, here is the dll code:

Public Function UpdateProduct(ByVal id As Long, Optional ByVal name As
String, _
    Optional ByVal details As String, Optional ByVal price As Double, _
    Optional ByVal cost As Double, Optional ByVal weight As Long, _
    Optional ByVal itemNumber As String, Optional ByVal size As String, _
    Optional ByVal stock As Long, Optional ByVal imageName As String) As
Long

    Dim UpdateQuery As New Recordset
    UpdateQuery.Open "select * from products where productid=" & id, _
        m_utility.DB.DB, adOpenKeyset, adLockOptimistic
    If name <> "" Then UpdateQuery("name") = name
    If details <> "" Then UpdateQuery("details") = details
    If price <> 0 Then UpdateQuery("price") = price
    If cost <> 0 Then UpdateQuery("cost") = cost
    If weight <> 0 Then UpdateQuery("weight") = weight
    If itemNumber <> "" Then UpdateQuery("itemNumber") = itemNumber
    If size <> "" Then UpdateQuery("size") = size
    If stock <> 0 Then UpdateQuery("stock") = stock
    UpdateQuery.Update
    UpdateQuery.Close
    Set UpdateQuery = Nothing
End Function



Tue, 28 Oct 2003 21:27:46 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Write String to ASP from ActiveX DLL Component

2. Error handling between ASP and ActiveX dll

3. Sending arrays from asp to activex dll

4. ActiveX DLL calling DLL procedures from ASP app...

5. *** Using ActiveX DLL on an ASP page ***

6. Passing an object to an ActiveX dll from ASP script

7. problem calling ActiveX dll from VBScript in ASP

8. ActiveX dll + ASP Pages - Compiling in Win 98

9. Calling VB ActiveX DLL from ASP...

10. Collection in ActiveX DLL (works in exe but not from ASP)

11. Updating a Database with an Activex DLL in an ASP with IIS

12. Pass array from ASP to VB ActiveX DLL

 

 
Powered by phpBB® Forum Software