using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace bankloan
{
static class Program
{
///
/// The main entry point for the application.
///
[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());
Jignesh TrivediPosted Mar 18, 2013, 8:41 AM
hi,
please refer below link, it might help you to resolve problem.
http://forums.asp.net/t/1755767.aspx/1
http://www.codeproject.com/Tips/333633/Error-Operation-is-not-valid-due-to-the-current-st
Vishal GilbilePosted Mar 18, 2013, 3:38 AM