Re: My COM always writes two same data in the system

Tech-Archive recommends: Speed Up your PC by fixing your registry



<tanya.wang@xxxxxxxxx> wrote in message
news:1185583815.679738.34390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For certain purposes I tried to add a record in my DB not using the
classic ASP way but going through a vb6.0-based Active X DLL file.
However it always adds two identical records at the same time. Have
tried on both IIS5.1 and 6.0 but get the same duplicate results.
Really have no clue. Any help will be appreciated. Thanks.

Here is the vb code - it is named "MyAddFile.vbp" with a class named
"AddNotes"

Option Explicit

Public Function AddNotes(SID As Variant, RID As Variant, Topic As
Variant, Content As Variant) As Boolean
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sConnString As String
Dim SQL As String

sConnString =

"provider=sqloledb;Server=myserverip,myport;UID=myuid;PWD=mypassword;databas
e=mydb;"
Set conn = New ADODB.Connection
conn.Open sConnString

Set rs = New ADODB.Recordset
rs.ActiveConnection = conn
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic

SQL = "my_table"

rs.Open (SQL)
rs.AddNew
rs("SID") = SID
rs("RID") = RID
rs("Topic") = Topic
rs("content") = Content
rs.Update
rs.Close
conn.Close
AddNotes = True

End Function


Here is the ASP code -
<%
Dim mycom
Dim addnotes_chk

set mycom=CreateObject("MyAddFile.AddNotes")


addnotes_chk=mycom.addNotes(request("SID"),request("RID"),request("Topic"),r
equest("content"))
response.write "<p>add notes check=" & addnotes_chk

Set mycom=nothing
%>


Have you tried calling the component using a simple VBScript file or better
yet a standard EXE VB6 test app to see whether the problem exists there.
This will help determine if the problem is with the component or how its
being called by ASP.

Are you sure the ASP page isn't being requested mutiple times?

Other tips, don't use the Requests default item property I can't remember
whether that returns form values or querystring values or both, its
ambiguous. Be explicit use either querystring or Form (in this case
preferably form).

Don't use a recordset for this type of operation use a command object with
parameters and INSERT statement.


--
Anthony Jones - MVP ASP/ASP.NET


.



Relevant Pages

  • Re: Type mismatch calling a COM object developed in vb6
    ... the OP's problem is that he needs to cast the variant ... Couldn't he also just change the dim statement to ... an .ASP page, all the parameters for that method *must* ... Now how do I pass an array of ProdOrd to a function in the COM object?: ...
    (comp.lang.basic.visual.misc)
  • Re: Type mismatch calling a COM object developed in vb6
    ... Now how do I pass an array of ProdOrd to a function in the COM object?: ... Public Function checkav(session As Variant, requestlist As Variant, ... dim arrResultas ProdOrd ... See if that helps on the result in your .ASP script. ...
    (comp.lang.basic.visual.misc)
  • Re: shape range help
    ... However initial use of Dim() avoided use of brackets and he ... Everytime with ReDim only, I get a Variant() ... never in a session I don't do the initial Dim varr() then redim does NOT ...
    (microsoft.public.excel.programming)
  • Re: Coding with varsortby and options
    ... Dim varhowsort As Variant ... DoCmd.OpenReport stDocName, acViewPreview ...
    (microsoft.public.access.formscoding)
  • Re: shape range help
    ... However initial use of Dim() avoided use of brackets and he ... Everytime with ReDim only, I get a Variant() ... Dim Stooges As ShapeRange ...
    (microsoft.public.excel.programming)