Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2008, 01:31 AM
MZA MZA is offline
Registered User
 
Join Date: Dec 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection expired

I develop a management system at which I make a connection with C# and Oracle. It work finely. But certainly it can not work and give the following message:

Operation is not valid due to the current state of the object.
At the line:Object Price0 = dr.getString(0);
of textPIDSell_TextChanged() method.

My code segment with 'usings' and the message are included.

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;

string oraDb = "Data Source=ORCZ;User Id=ebazar;password=ebazar;";
        OracleConnection Conn;

private void txtPIDSell_TextChanged(object sender, EventArgs e)
        {
            if (txtPIDSell.Text.Length == 5)
            {
                OracleDataReader dr = DynamicReader("Name,PUSP,scale","Product","Where ID = " + txtPIDSell.Text );
                object price0 = dr.GetValue(0);
                txtPNameSell.Text = price0.ToString();
                object price1 = dr.GetValue(1);
                txtPriceSell.Text = price1.ToString();
                object price2 = dr.GetValue(2);
                lblPerUnitSell.Text = "Per "+price2.ToString();
                lblUnitSell.Text = price2.ToString();
                Conn.Close();
            }
        }


public OracleDataReader DynamicReader(string fieldNms, string TableNms, string condition)
        {
            string oraDb = "Data Source=ORCZ;User Id=ebazar;password=ebazar;";
            Conn = new OracleConnection(oraDb);
            Conn.Open();
            if (condition.Length > 0)
                condition = " " + condition;
            string sql = "Select " + fieldNms + " from " + TableNms + condition;
            OracleCommand cmd = new OracleCommand(sql, Conn);
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr = cmd.ExecuteReader();
            dr.Read();
            return dr;
        }





Similar Threads
Thread Thread Starter Forum Replies Last Post
Timeout expired ks2006 ASP.NET 2.0 Basics 12 September 8th, 2006 03:54 PM
TimeOut Expired Lalit_Pratihari SQL Server 2000 1 July 23rd, 2006 12:59 PM
Timeout expired glibo SQL Server 2000 6 July 21st, 2006 11:58 AM
Timeout expired ssingh SQL Server 2000 4 April 19th, 2004 11:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.