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();
}


Iftikar HussainRank #423 · 5.9K reputationPosted Jul 23, 2013, 4:12 AM EDT
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
Sunny SharmaRank #223 · 11.1K reputationPosted Jul 23, 2013, 4:27 AM EDT
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.
Kavi sujaRank #6,237 · 272 reputationPosted Jul 23, 2013, 4:53 AM EDT
Now I use 3-tier architecture here.Here how i use oops concept?
Kavi sujaRank #6,237 · 272 reputationPosted Jul 23, 2013, 5:09 AM EDT
Santosh KumarRank #2,303 · 613 reputationPosted Jul 29, 2013, 9:13 AM EDT
using (MySqlConnection con = new MySqlConnection("server=localhost;User Id=root;database=userdata;password=MySqlAdmin"))
.
.