Ask a Question related to ASP Components, Design and Development.
-
tanya.wang@gmail.com #1
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
-
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... -
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... -
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... -
Columbia professor writes about SCO case
This article was written by a Columbia University professor who happens to be GNU's consel. -Ramon ... -
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... -
Anthony Jones #2
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..."provider=sqloledb;Server=myserverip,myport;UID=my uid;PWD=mypassword;databas> 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 =
>
e=mydb;"addnotes_chk=mycom.addNotes(request("SID"),request ("RID"),request("Topic"),r> 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")
>
>
equest("content"))Have you tried calling the component using a simple VBScript file or better> response.write "<p>add notes check=" & addnotes_chk
>
> Set mycom=nothing
> %>
>
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
-
tanya.wang@gmail.com #3
Re: My COM always writes two same data in the system
On Jul 28, 10:22 am, "Anthony Jones" <A...@yadayadayada.com> wrote:
Thanks for the input Anthony.> 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 -
>
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
-
Anthony Jones #4
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...better> On Jul 28, 10:22 am, "Anthony Jones" <A...@yadayadayada.com> wrote:> > Have you tried calling the component using a simple VBScript file orremember> > 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'twith> > 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 objectI never know where to find good examples of simple how to. Here is a>> > 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.
>
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
-
tanya.wang@gmail.com #5
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
-
Anthony Jones #6
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 it does sound like a forms contents is being posted twice.> 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.
>
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



Reply With Quote

