I have register page and view page.In Register page I insert data in to database.In view page,all the data entered in Register page will be shown in Grid.I use Stored procedure for this.Now I've to done this task using anyone of oops concept.But i don't know so much about oops concept.How I use oops concept here?Can anyone help me to do this?
I include my code here:
protected void Page_Load(object sender, EventArgs e)
{
con = new MySqlConnection("server=localhost;User Id=root;database=userdata;password=MySqlAdmin");
con.Open();
if (!IsPostBack)
{
BindGridView();
}
}
private void BindGridView()
{
using (MySqlConnection con = new MySqlConnection("server=localhost;User Id=root;database=userdata;password=MySqlAdmin"))
{
DataSet ds = new DataSet();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "viewdata";
cmd.Connection = con;
try
{
con.Open();
gvcontact.EmptyDataText = "No Records Found";
gvcontact.DataSource = cmd.ExecuteReader();
gvcontact.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}

Santosh KumarPosted Jul 29, 2013, 1:13 PM
using (MySqlConnection con = new MySqlConnection("server=localhost;User Id=root;database=userdata;password=MySqlAdmin"))
.
.
Kavi sujaPosted Jul 23, 2013, 9:09 AM
Kavi sujaPosted Jul 23, 2013, 8:53 AM
Now I use 3-tier architecture here.Here how i use oops concept?
Sunny SharmaPosted Jul 23, 2013, 8:27 AM
Since you have to apply OOPS concept, you already have done it. The approach other than Stored Procedure probably means, as I assume, to implement the DB server side logic at Application Layer. Just implement the logic in your query string and you're ready to go. Change the Commandtype as Text and replace "viewdata" with your query string. I think that's all you need to do.
Hope it helps.
Iftikar HussainPosted Jul 23, 2013, 8:12 AM
You can first implement 3-tier architecture and then you can use OOPS over there. Please refer below link
http://www.dotnetfunda.com/articles/article71.aspx
http://www.aspdotnet-suresh.com/2010/05/introduction-to-3-tier-architecture-in_17.html
Regards,
Iftikar