My COM always writes two same data in the system

Ask a Question related to ASP Components, Design and Development.

  1. #1

    Default My COM always writes two same data in the system

    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=my uid;PWD=mypassword;database=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"),request("content"))
    response.write "<p>add notes check=" & addnotes_chk

    Set mycom=nothing
    %>

    tanya.wang@gmail.com Guest

  2. Similar Questions and Discussions

    1. IO::Pty - reads/writes fail *only* with system()
      Starting from the example in the IO::Pty man page I've now got a perl script which forks, the child reopens stdin/stdout on the slave side of the...
    2. Slow writes to 2003 server
      Hi gents, I've got a very perplexing problem here that's been nagging me for the last two weeks. We have recently deployed a new sever in our...
    3. fput writes 0kb file
      Hi I'm having a lot of trouble with this and I hope someone can help. I'm writing a script that is installed on many different servers, so...
    4. Columbia professor writes about SCO case
      This article was written by a Columbia University professor who happens to be GNU's consel. -Ramon ...
    5. Finding system data with system calls.
      I'd like to obtain some data about a machine that runs AIX in a C program. Hence I don't want to use utilities at the command line, but system...
  3. #2

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

    <tanya.wang@gmail.com> wrote in message
    news:1185583815.679738.34390@l70g2000hse.googlegro ups.com...
    > 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=my uid;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


    Anthony Jones Guest

  4. #3

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

    On Jul 28, 10:22 am, "Anthony Jones" <A...@yadayadayada.com> wrote:
    > 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- Hide quoted text -
    >
    Thanks for the input Anthony.

    I tried to write a vb6 app EXE and call my DLL file to insert into
    myDB, and I found it works fine - ie. no duplicate rows were inserted.
    Now it makes me doubt that either my asp page was requested twice, or
    my IIS setting has some problems that I cannot figure out.
    Or, there's another DLL activated when I request my asp page (just my
    speculation)

    Even if I modified all my request fields to Request.form("XXX"), my
    asp page still gives me duplicate rows...

    What exactly does that mean by
    "Don't use a recordset for this type of operation use a command object
    with
    parameters and INSERT statement."
    If you have any reference urls to elaborate this it would be great.

    Thank you very much.

    tanya.wang@gmail.com Guest

  5. #4

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

    <tanya.wang@gmail.com> wrote in message
    news:1185902414.060547.67640@g4g2000hsf.googlegrou ps.com...
    > On Jul 28, 10:22 am, "Anthony Jones" <A...@yadayadayada.com> wrote:
    > > 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- Hide quoted text -
    > >
    >
    > Thanks for the input Anthony.
    >
    > I tried to write a vb6 app EXE and call my DLL file to insert into
    > myDB, and I found it works fine - ie. no duplicate rows were inserted.
    > Now it makes me doubt that either my asp page was requested twice, or
    > my IIS setting has some problems that I cannot figure out.
    > Or, there's another DLL activated when I request my asp page (just my
    > speculation)
    >
    > Even if I modified all my request fields to Request.form("XXX"), my
    > asp page still gives me duplicate rows...
    >
    > What exactly does that mean by
    > "Don't use a recordset for this type of operation use a command object
    > with
    > parameters and INSERT statement."
    > If you have any reference urls to elaborate this it would be great.
    >
    I never know where to find good examples of simple how to. Here is a
    sample:-

    sSQL = "INSERT My_Table (SID, RID, Topic, content) Values (?, ?, ?, ?)"

    Set cmd = New ADODB.Command

    cmd.ActiveConnection = conn
    cmd.CommandType = adCmdText
    cmd.CommandText = sSQL

    cmd.parameters.append cmd.createParameter("@SID", adInteger, adParamInput, ,
    SID)
    cmd.parameters.append cmd.createParameter("@RID", adInteger, adParamInput, ,
    RID)
    cmd.parameters.append cmd.createParameter("@Topic", adVarWChar,
    adParamInput, 50, Topic)
    cmd.parameters.append cmd.createParameter("@Content", adVarWChar,
    adParamInput, 4000, content)

    cmd.Execute




    --
    Anthony Jones - MVP ASP/ASP.NET


    Anthony Jones Guest

  6. #5

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

    ok, here is some update -

    I tried to revise my vb6 COM with the suggested method. It works well
    in VB6 APP but I still receive the same situation in IE7.
    What's more, if I use Firefox to call this asp page, it works great!
    No more multiple rows no matter how many time I inserted it.

    Now it makes me speculate it's the client browser problem...

    I have tried to search some related articles in this group and found
    some people have the similar situation as mine, but no solutions were
    mentioned.
    Really wonder where the problem is since it has confused me so many
    weeks.

    Thank you very much.

    tanya.wang@gmail.com Guest

  7. #6

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

    <tanya.wang@gmail.com> wrote in message
    news:1187808913.043639.154180@i13g2000prf.googlegr oups.com...
    > ok, here is some update -
    >
    > I tried to revise my vb6 COM with the suggested method. It works well
    > in VB6 APP but I still receive the same situation in IE7.
    > What's more, if I use Firefox to call this asp page, it works great!
    > No more multiple rows no matter how many time I inserted it.
    >
    > Now it makes me speculate it's the client browser problem...
    >
    > I have tried to search some related articles in this group and found
    > some people have the similar situation as mine, but no solutions were
    > mentioned.
    > Really wonder where the problem is since it has confused me so many
    > weeks.
    >
    Ok it does sound like a forms contents is being posted twice.

    Get this tool. [url]http://www.fiddlertool.com/[/url] it allows you to see what IE is
    sending to the server. If it is sending things twice then this will
    highlight it.

    Note the tool is a proxy which automatically configures IEs proxy settings.
    To use it with firefox take a look at the settings it makes for IE and
    duplicate them in FFs options in advanced networking.


    --
    Anthony Jones - MVP ASP/ASP.NET


    Anthony Jones Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139