Re: My COM always writes two same data in the system
- From: "Anthony Jones" <Ant@xxxxxxxxxxxxxxxx>
- Date: Sat, 28 Jul 2007 18:22:37 +0100
<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"provider=sqloledb;Server=myserverip,myport;UID=myuid;PWD=mypassword;databas
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 =
e=mydb;"
Set conn = New ADODB.Connectionaddnotes_chk=mycom.addNotes(request("SID"),request("RID"),request("Topic"),r
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")
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
.
- Follow-Ups:
- Re: My COM always writes two same data in the system
- From: tanya . wang
- Re: My COM always writes two same data in the system
- References:
- My COM always writes two same data in the system
- From: tanya . wang
- My COM always writes two same data in the system
- Prev by Date: Re: ASP call a COM but got Error Code = 0x8002801d : Library not registered.
- Next by Date: Re: My COM always writes two same data in the system
- Previous by thread: My COM always writes two same data in the system
- Next by thread: Re: My COM always writes two same data in the system
- Index(es):
Relevant Pages
|