i messing around with my first c# web application developed in visual studio.net.
the compile/build is successful, but i keep getting the same runtime error -  
Operation is not allowed when the object is closed (see below).  the error points to 
the "finally" exception handling and occurs when i input search criteria on the 
webform and click the search button, i receive a server error.  any ideas??

thanks,
[EMAIL PROTECTED]
-------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace SWPFirstTry
{
        /// <summary>
        /// Summary description for WebForm1.
        /// </summary>
        public class SWPFirstTryLookup : System.Web.UI.Page
        {
                protected System.Web.UI.WebControls.Label LabelTradeNameSearch;
                protected System.Web.UI.WebControls.Label LabelTradeName;
                protected System.Web.UI.WebControls.Label LabelIngredients;
                protected System.Web.UI.WebControls.Label LabelDosageRoute;
                protected System.Web.UI.WebControls.Label LabelStrength;
                protected System.Web.UI.WebControls.Label LabelType;
                protected System.Web.UI.WebControls.Label LabelQueryTime;
                protected System.Web.UI.WebControls.Button ButtonSearch;
                protected System.Web.UI.WebControls.DropDownList DropDownListTradeName;
                protected System.Web.UI.WebControls.DropDownList 
DropDownListIngredients;
                protected System.Web.UI.WebControls.DropDownList 
DropDownListDosageRoute;
                protected System.Web.UI.WebControls.DropDownList DropDownListStrength;
                protected System.Web.UI.WebControls.DropDownList DropDownListType;
                protected System.Web.UI.WebControls.TextBox TextBoxTradeName;
                protected System.Web.UI.WebControls.Label LabelError;
        
                private void Page_Load(object sender, System.EventArgs e)
                {
                        // Put user code to initialize the page here
                }

                #region Web Form Designer generated code
                override protected void OnInit(EventArgs e)
                {
                        //
                        // CODEGEN: This call is required by the ASP.NET Web Form 
Designer.
                        //
                        InitializeComponent();
                        base.OnInit(e);
                }
                
                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InitializeComponent()
                {    
                        this.ButtonSearch.Click += new 
System.EventHandler(this.ButtonSearch_Click);
                        this.Load += new System.EventHandler(this.Page_Load);
                }
                #endregion

                private void ButtonSearch_Click(object sender, System.EventArgs e)
                {
                        if ((TextBoxTradeName.Text == null) || 
(TextBoxTradeName.Text.Length == 0))
                        {
                                LabelError.Text = "No item specified";
                                SWPTweakAllDropDownLists(false);
                                return;
                        }
                        LabelError.Text = "";
                        ADODB.Connection conn = null;
                        DateTime startTime = DateTime.Now;
                        try
                        {
                                conn = new ADODB.ConnectionClass();
                                conn.ConnectionString = "PROVIDER=sqloledb;" + 
"Database=SWPMedicalStuff";
                                conn.Open(null, null, null, 
(int)ADODB.ConnectModeEnum.adModeUnknown);
                                SWPFillItIn(conn);
                        }
                        catch(Exception ex)
                        {
                                SWPTweakAllDropDownLists(false);
                                LabelError.Text = ex.Message;
                        }
                        finally
                        {
                                if (null != conn)
                                {
                                        conn.Close();
                                        conn = null;
                                }
                        }
                        TimeSpan duration = DateTime.Now - startTime;
                        LabelQueryTime.Text = String.Format("Query time: {0:N} ms", 
duration.TotalMilliseconds);
                }
                const string listData =
                        "SELECT Col001 As Ingredients, " + 
                                        "Col002 As DosageRoute, " +
                                        "Col003 As TradeName, " +
                                        "Col005 As Strength, " +
                                        "Col011 As Type, " +
                                        "FROM Approved " +
                                        "WHERE Col003='{0}'";
                private void SWPFillItIn(ADODB.Connection conn)
                {
                        string commandText = String.Format(listData, 
TextBoxTradeName.Text);
                        //string commandText = String.Format(" 
",TextBoxTradeName.Text);
                        //string commandText = TextBoxTradeName.Text;
                        Object recordsAffected;
                        ADODB.Recordset rs = null;

                        try
                        {
                                rs = conn.Execute(commandText, out recordsAffected, 
(int)ADODB.ConnectModeEnum.adModeUnknown);
                                SWPClearAllDropDownLists();
                                while (!rs.EOF)
                                {
                                        
DropDownListIngredients.Items.Add(rs.Fields["Ingredients"].Value.ToString());
                                        
DropDownListDosageRoute.Items.Add(rs.Fields["DosageAndRoute"].Value.ToString());
                                        
DropDownListTradeName.Items.Add(rs.Fields["TradeName"].Value.ToString());
                                        
DropDownListStrength.Items.Add(rs.Fields["Strength"].Value.ToString());
                                        
DropDownListType.Items.Add(rs.Fields["Type"].Value.ToString());
                                        rs.MoveNext();
                                                                                       
                                         
                                }
                                SWPTweakAllDropDownLists(true);
                        }
                        finally
                        {
                                if (null != rs)
                                {
                                        rs.Close();
                                        rs = null;
                                }
                        }
                }
                private void SWPClearAllDropDownLists()
                {
                        DropDownListIngredients.Items.Clear();
                        DropDownListDosageRoute.Items.Clear();
                        DropDownListTradeName.Items.Clear();
                        DropDownListStrength.Items.Clear();
                        DropDownListType.Items.Clear();
                }
                private void SWPTweakAllDropDownLists(bool visible)
                {
                        DropDownListIngredients.Visible = visible;
                        DropDownListDosageRoute.Visible = visible;
                        DropDownListTradeName.Visible = visible;
                        DropDownListStrength.Visible = visible;
                        DropDownListType.Visible = visible;
                }
                private void SWPChangeAllDropDownListsIndexes(int index)
                {
                        DropDownListIngredients.SelectedIndex = index;
                        DropDownListDosageRoute.SelectedIndex = index;
                        DropDownListTradeName.SelectedIndex = index;
                        DropDownListStrength.SelectedIndex = index;
                        DropDownListType.SelectedIndex = index;
                }
                
                private void DropDownListGeneric_SelectedIndexChanged(object sender, 
System.EventArgs e)
                {
                        
SWPChangeAllDropDownListsIndexes(((DropDownList)sender).SelectedIndex);
                }
        }
}
-------------------------------------

-----Original Message-----
From: deb [mailto:[EMAIL PROTECTED]]
Sent: Saturday, September 21, 2002 6:20 AM
To: ActiveServerPages
Subject: RE: Asp.net beginning


Paul
I highly recomed www.asp.net
I think that this site has much information that could help you as well as
a very informative forum for help in learning. Also there is a place
called Hiveminds.com you might want to give them a check out as well.

---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to