FCI-Helwan blog

Just another FCI-H weblog

Code Snippet :Oracle via C#

Select statement :

OracleCommand myOracleCommand = new OracleCommand();

OracleConnection myOracleConn = new OracleConnection();

myOracleConn.ConnectionString = “user id=userid ; data source=ERPDEV ; password=xxxxx”;


myOracleCommand.Connection = myOracleConn;



string strSQLFields = “select QUESTIONANSWER from FCIH where QUESTIONTEXT =’any text’ ROWNUM <= 2)";

myOracleCommand.CommandText = strSQLFields;

myOracleCommand.CommandType = CommandType.Text;

OracleDataReader OracleDataReader1 = myOracleCommand.ExecuteReader();

if (OracleDataReader1.Read())


if (!(OracleDataReader1.IsDBNull(0)))


answer = OracleDataReader1.GetString(0);



if (!OracleDataReader1.IsClosed)


if (myOracleConn.State == ConnectionState.Open)



catch (Exception ex)


throw new ArgumentException(ex.Message.ToString());


Insert statment :

//new record

OracleCommand myOracleCommand4Insert = new OracleCommand();

OracleConnection myOracleConn4Insert = new OracleConnection();

myOracleConn4Insert.ConnectionString = “user id=ultimus ; data source=ERPDEV ; password=kmbpm263”;


myOracleCommand4Insert.Connection = myOracleConn4Insert;




string strSQLValues4Insert = “:TENDERNAME,TENDERNO.NEXTVAL”;

string strSQL4Insert = strSQLFields4Insert + ” VALUES (“ + strSQLValues4Insert + “)”;

myOracleCommand4Insert.CommandText = strSQL4Insert;

myOracleCommand4Insert.CommandType = CommandType.Text;

myOracleCommand4Insert.Parameters.Add(“TENDERNAME”, “any tender name”);



catch (Exception ex)


throw new ArgumentException(“Error In Insert You Suggestions to DataBase: “ + ex.Message.ToString());



July 10, 2008 - Posted by | Uncategorized


  1. That’s after they have seen ADO.NET, they develop (ODP) to make easier for developers to connect to Oracle DB and looks like ADO.NET classes which meets .net developers mental to work with Oracle like SQL Server

    Thanks, Oracle team

    Comment by Ramy Mahrous | July 10, 2008 | Reply

  2. Hi,

    the Article is good for the beginners. But the bracing is not possibly opened and closed where it has to be. It might be replaced. Could you check it and correct so that it would be helpful for other who read this article in future.

    Comment by Dharmaraj | September 29, 2008 | Reply

  3. The first wow gold thing for wow gold you to consider buy wow gold about the buy wow gold Druid class cheap wow gold is this: Is the cheap wow gold Druid class wow power leveling right for wow power leveling you? The power leveling Druid class power leveling is kind of wow gold unique in that buy wow gold it’s not for cheap wow gold everyone. While world of warcraft gold master of none.

    Comment by wow gold | February 17, 2009 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: