Add the Reference of System.Data.OracleClient.
and then ...
using System.Data.OracleClient;
using System.Data;
public void LoadData()
{
string strConn = "Data Source=Data Source Name;User ID=userId;Password=password;";
using (OracleConnection objConnection = new OracleConnection())
{
objConnection.ConnectionString = strConn;
try
{
objConnection.Open();
OracleCommand objCommand = new OracleCommand();
objCommand.Connection = objConnection;
objCommand.CommandText = "select ID,NAME from Employee";
objCommand.CommandType = System.Data.CommandType.Text;
OracleDataAdapter objAdapter = new OracleDataAdapter(objCommand);
DataTable objTable = new DataTable();
objAdapter.Fill(objTable);
grid1.DataSource = objTable;
grid1.DataBind();
objConnection.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
objConnection.Close();
}
}
}
Enjoy....
and then ...
using System.Data.OracleClient;
using System.Data;
public void LoadData()
{
string strConn = "Data Source=Data Source Name;User ID=userId;Password=password;";
using (OracleConnection objConnection = new OracleConnection())
{
objConnection.ConnectionString = strConn;
try
{
objConnection.Open();
OracleCommand objCommand = new OracleCommand();
objCommand.Connection = objConnection;
objCommand.CommandText = "select ID,NAME from Employee";
objCommand.CommandType = System.Data.CommandType.Text;
OracleDataAdapter objAdapter = new OracleDataAdapter(objCommand);
DataTable objTable = new DataTable();
objAdapter.Fill(objTable);
grid1.DataSource = objTable;
grid1.DataBind();
objConnection.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
objConnection.Close();
}
}
}
Enjoy....
No comments:
Post a Comment