protected void btnInsert_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string Name = txtBookName.Text;
string Author = txtAuthor.Text;
string Publisher = txtPublisher.Text;
string Price = txtPrice.Text;
//save photo
string path = MapPath("~/Photos/");
string filename = Guid.NewGuid().ToString("N") + ".jpg";
SimpleImage img = new SimpleImage(fupPhoto.FileContent);
img.Square();
img.Resize(150);
img.SaveAs(path + filename);
Book b = new Book
{
name = Name,
author = Author,
publisher = Publisher,
price = Price,
photo = filename
};
db.Books.InsertOnSubmit(b);
db.SubmitChanges();
Response.Redirect("List.aspx");
}
}
Asked
Active
Viewed 294 times
0

Gilad Green
- 36,708
- 7
- 61
- 95

M. Wong
- 1
-
Additional information: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Book_Seller". The conflict occurred in database "C:" – M. Wong Mar 07 '16 at 16:30
-
the problem occurs with this: db.SubmitChanges(); – M. Wong Mar 07 '16 at 16:30