Re: Operation is not allowed...
From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 08/24/04
- Next message: gil: "String not recogized as array"
- Previous message: Danny: "Re: how to make dynamic ASP pages more readable?"
- In reply to: James Baker: "Re: Operation is not allowed..."
- Next in thread: James Baker: "Re: Operation is not allowed..."
- Reply: James Baker: "Re: Operation is not allowed..."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 24 Aug 2004 18:13:05 -0400
James Baker wrote:
> If the connection is open, can I execute two statements against it
> before I close the connection?
Absolutely. Did you have a problem doing it?
> I'm opening the one recordset I'm
> using with it and I'm also potentially executing the INSERT with it
> as well. Ultimately I rewrote my code (pre-Stored Procedure) as:
Looks good.
>
> Dim cmsRS, cmsSQL
> Dim insSQL
>
> Dim cn
> Set cn = Server.CreateObject("ADODB.Connection")
> cn.Open "Provider=SQLOLEDB;" & _
> "Data Source=XXXXX;" & _
> "Initial Catalog=XXXXX;" & _
> "User ID = XXXXX;Password=XXXXX"
>
> Set cmsRS = Server.CreateObject("ADODB.Recordset")
>
> cmsSQL = "SELECT ClientsFileNumber FROM TblOrder WHERE FileNumber =
> '" & filenumber & "' AND ClientCode = 'CMSNY'"
Can this return more than one record? If so, you can streamline things by
changing it to:
cmsSQL = "SELECT Count(ClientsFileNumber) FROM TblOrder WHERE " & _
"FileNumber = '" & filenumber & "' AND ClientCode = 'CMSNY'"
> cmsRS.Open cmsSQL, cn, , , 1
>
And change this:
> If NOT cmsRS.EOF Then
To:
If cmsRS(0) > 0 then 'if the first field of the recordset contains a value >
0
> insSQL = "INSERT INTO CMS (FileNumber, StatusDate, StatusTime,
> StatusComment) VALUES('" & cmsRS("ClientsFileNumber") & "', '" &
> date() & "', '" & adstime & "', 'Order has entered review process')"
> cn.Execute insSQL,,129
> End If
>
> cmsRS.Close
> Set cmsRS = Nothing
> cn.Close
Don't forget:
Set cn=nothing
Although some will argue against the need to do that given that you've
destroyed all the child objects first ...
Bob Barrows
-- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
- Next message: gil: "String not recogized as array"
- Previous message: Danny: "Re: how to make dynamic ASP pages more readable?"
- In reply to: James Baker: "Re: Operation is not allowed..."
- Next in thread: James Baker: "Re: Operation is not allowed..."
- Reply: James Baker: "Re: Operation is not allowed..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|