473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Write and if statement

Hi all

i got the part of this code i have written
Expand|Select|Wrap|Line Numbers
  1. Set CmdApp = Server.CreateObject("ADODB.Command")
  2.     CmdApp.ActiveConnection = c
  3.     CmdApp.CommandText = "sp_ Attachment"
  4.     CmdApp.CommandType = adCmdStoredProc
  5.  
  6.     Set Param =CmdApp.CreateParameter("@Id",adInteger,adParamInput,4,Id)
  7.     CmdApp.Parameters.Append Param
  8.  
  9.     set    RS=CmdApp.Execute
  10.     Set CmdApp = Nothing
  11.  
no i want to add tht if Id = 0 then i dont want to call the sp_Attachment
i tried adding it
n i m gettin error in application and it says :
Operation is not allowed when the object is closed.
how do I go on .
Please help

Thanks in advance
Oct 24 '07 #1
1 1129
markrawlingson
346 Expert 100+
"Operation is not allowed when the object is closed" Usually means that you're trying to close an object that isn't open, or you're trying to clean up an object which is open. Most likely cause of this is that you've opened your in an if statement, and you're closing the object outside of the if statement. This means that if the if statement is not true, the object will not get created.

You would want to do something like the following...

Expand|Select|Wrap|Line Numbers
  1. If condition = "condition" Then
  2.    Set CmdApp = Server.CreateObject("ADODB.Command")
  3.    CmdApp.ActiveConnection = c
  4.    CmdApp.CommandText = "sp_ Attachment"
  5.    CmdApp.CommandType = adCmdStoredProc
  6.    Set Param =CmdApp.CreateParameter("@Id",adInteger,adParamInput,4,Id)
  7.    CmdApp.Parameters.Append Param
  8.    Set RS=CmdApp.Execute
  9.    CmdApp.Close
  10.    Set CmdApp = Nothing
  11. End If
  12.  
If condition is equal to "condition" - the object is created, your work is done, you close the object and cleanup. If condition does not equal "condition" then the object is not created, therefore there is no need to clean it up outside of the if statement.

Sincerely,
Mark
Oct 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is...
2
by: Jack | last post by:
Hi, I am trying to check for the final sql statement before passing it to a database. I want to build the statement using user input in three text boxes. However, the sql statement does not give...
1
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
3
by: TD | last post by:
I have an unbound form that adds and updates records to one table. I use an INSERT sql statment to add a new record and a UPDATE statement to update a record. I created a function named C2F to...
1
by: =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post by:
Hello All, Our application write logs to a file in a folder. Before our application starts writing to that file, I want to check if the current user has write access to that file, for example,...
12
by: =?Utf-8?B?Smlt?= | last post by:
I have code that reads and parses a text file using a schema.ini file. Works great. When I see the dataGrid it's exactly what I want. Dim CString As String = _...
23
by: asit dhal | last post by:
hello friends, can anyone explain me how to use read() write() function in C. and also how to read a file from disk and show it on the monitor using onlu read(), write() function ??????
2
by: chrisf01 | last post by:
I am trying to write to a text file and the database at the same time. I have a For statement that loops through all the repeated fields in my form and writes it to a text file. That part works 100%...
3
by: Alan Mailer | last post by:
Ok, I've looked for an answer for this, because I'm sure it's been asked a thousand times... but no luck... so here goes. Imagine I want to create a NodeList based on an XPath statement. The...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.