I want to insert the data from two TextBoxes into a databse using LINQ to SQL. I have the following code:
private void button1_Click(object sender, EventArgs e)
{
DataClasses1DataContext db = new DataClasses1DataContext();
Customer cust = new Customer();
cust.FirstName = textBox1.Text;
cust.LastName = textBox1.Text;
db.Customers.InsertOnSubmit(cust);
db.SubmitChanges();
}
When I run the program nothing happens, I don't get any errors and nothing gets saved to the database. What am I doing wrong ?
The code was actually working fine. I had to add the database from the Debug folder to the Database Explorer to view the entered records.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.