d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > How Do I Call This Method And Its Property?
Prev12
Add Reply New Topic New Poll
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Oct 16 2012 06:40pm
Quote (JuicyFruitSweeT @ Oct 16 2012 07:22pm)
Should I get a dataGridView and use this property I made to display Records?
Is that even possible?


Did you not get the part where someone pointed out that you are abusing properties and that's not how you should be doing that? You are embedding a lot of logic into a property and that's probably not right. Refactor your code.
Member
Posts: 7,427
Joined: Aug 22 2008
Gold: 2,334.50
Oct 16 2012 06:46pm
I followed this tutorial and that's what I got.

http://msdn.microsoft.com/en-us/library/ms227647v=vs.80.aspx

Not sure why the tutorial told me to do all those when I could just write this in my Form1.cs and it still works perfectly.

Code

OleDbConnection con = new OleDbConnection();

private void btnLoadRecords_Click(object sender, EventArgs e)
       {            
           con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=myprojectname\\xtreme.mdb";
           con.Open();

           DataSet ds = new DataSet();
           DataTable dt = new DataTable();
           ds.Tables.Add(dt);

           OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM CUSTOMER", con);
           da.Fill(dt);

           dataGridView1.DataSource = dt.DefaultView;
           con.Close();
       }


This post was edited by JuicyFruitSweeT on Oct 16 2012 06:49pm
Member
Posts: 7,427
Joined: Aug 22 2008
Gold: 2,334.50
Oct 16 2012 08:37pm
Never-mind I actually finished this assignment before asking silly questions on here LOL.....

Friend said I'm done :D

Thanks for the help anyways.
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll