rohit jadhav

rohit jadhav

  • NA
  • 1
  • 18k

{"Operation is not valid due to the current state of the obj

Mar 18 2013 2:23 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace bankloan
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace bankloan
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string oradb = "Data Source=ORCL;User Id=scott;Password=tiger;";
            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select count(*) from result";
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr = cmd.ExecuteReader();
            dr.Read();
            int abc = int.Parse(string.Format("{0}", dr.GetValue(0)));
            MessageBox.Show(String.Empty + abc);
            cmd.CommandText = "insert into result values('no','yes','55')";
            cmd.ExecuteNonQuery();
            conn.Dispose();
            MessageBox.Show("table truncated");

        }
    }
}
getting error using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace bankloan
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string oradb = "Data Source=ORCL;User Id=scott;Password=tiger;";
            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select count(*) from result";
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr = cmd.ExecuteReader();
            dr.Read();
            int abc = int.Parse(string.Format("{0}", dr.GetValue(0)));
            MessageBox.Show(String.Empty + abc);
            cmd.CommandText = "insert into result values('no','yes','55')";
            cmd.ExecuteNonQuery();
            conn.Dispose();
            MessageBox.Show("table truncated");

        }
    }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace bankloan
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string oradb = "Data Source=ORCL;User Id=scott;Password=tiger;";
            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select count(*) from result";
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr = cmd.ExecuteReader();
            dr.Read();
            int abc = int.Parse(string.Format("{0}", dr.GetValue(0)));
            MessageBox.Show(String.Empty + abc);
            cmd.CommandText = "insert into result values('no','yes','55')";
            cmd.ExecuteNonQuery();
            conn.Dispose();
            MessageBox.Show("table truncated");

        }
    }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace bankloan
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string oradb = "Data Source=ORCL;User Id=scott;Password=tiger;";
            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select count(*) from result";
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr = cmd.ExecuteReader();
            dr.Read();
            int abc = int.Parse(string.Format("{0}", dr.GetValue(0)));
            MessageBox.Show(String.Empty + abc);
            cmd.CommandText = "insert into result values('no','yes','55')";
            cmd.ExecuteNonQuery();
            conn.Dispose();
            MessageBox.Show("table truncated");

        }
    }
}
getting error {"Operation is not valid due to the current state of the object."}
at line    Application.Run(new Form1()); 

Answers (2)