Help with passing data base information into my class methods!!!
Hi guys. I'm new to C# though I have programming experiences with other languages. My question seems too noobie but the true is that I was raised programming at low level. This high level things are new for me so... sorry if this is really easy.
What i'm trying to do is to pass some information from a data base via parameters to my class method. Here's my class:
Code:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Relationship_Management
{
public class Individual
{
private int id;
private string name;
private string lastName;
private string existingRelation;
private string microsoftFriendly;
private string hasBudget;
private string underRadar;
private int reportTo;
public int ID
{
get { return id; }
set { id = value;}
}
public string Name
{
get { return name; }
set { name = value; }
}
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
public string ExistingRelation
{
get { return existingRelation; }
set { existingRelation = value; }
}
public string MicrosoftFriendly
{
get { return microsoftFriendly; }
set { microsoftFriendly = value; }
}
public string HasBudget
{
get { return hasBudget; }
set { hasBudget = value; }
}
public string UnderRadar
{
get { return underRadar; }
set { underRadar = value; }
}
public int ReportTo
{
get { return reportTo; }
set { reportTo = value; }
}
}
}
So when I go to main, I can do something like this:
Code:
Individual person = new Individual();
person.ReportTo = 345;
Now, that number is suppose to be a random ID number that a DBMS generate automatically. My question is this... HOW IN THE WORLD can I do to pass fields of the data base or any info. of a table to my object fields? I mean something like this:
Code:
Individual person = new Individual();
// person.ReportTo = TableName.ID (data base info);
Or there is a way via query to assing a data base value to a variable? I hope that I explained myself well enough and sorry about my english. Is not my main language. I will waiting for your answers people.
Many thanks
I think I found in Google what I was looking for BUT....
I think I found what I was looking for in Google but damn... it seems kinda complicated. Would someone try to explain me in english at least?
Here's the link: How To Use A Database In Your Program Part II - .NET Framework
Waiting for your answers. Thank you again