In this example we have show how to execute the parameterized query in odp.net. so I have table tkt_user and get all the active user list in this example given below
string query = @"SELECT * FROM tkt_user where is_active=:isactive";
var conn = new OracleConnection("Your connection string path ");
OracleCommand cmd = null;
try
{
conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("", 1);
IDataReader rdrBrowsers = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(rdrBrowsers);
if (dt.Rows.Count > 0)
{
GridView gv = new GridView();
gv.DataSource = rdrBrowsers;
gv.DataBind();
}
}
catch
{
}
finally
{
cmd.Dispose();
conn.Close();
conn.Dispose();
}
No comments:
Post a Comment