I'm a newbie to c# and am having some difficulty getting an integer from a textbox to a database.
I have created a simple form which allows a user to input their firstName, lastName, and age.
I can connect the firstName and lastName to the database on a buttonClick, but am unable to to the same with age. Here is what I have.
private void AddTheNewInfoToDB()
{
using (DatabaseContainer db = new DatabaseContainer())
{
Users u = new Users();
u.firstName = textboxfirstName.Text;
u.lastName = textboxlastName.Text;
u.Age = textboxAge.Text;
db.Users.AddObject(u);
db.SaveChanges();
}
When I do this, I get an error for the "textboxAge.Text" which says "Cannot implicitly convert tye 'string' to 'int'."
Advice on fixing this would be appreciated.