M. Wong
M. Wong

Reputation: 1

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.Linq.dll but was not handled in user code

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");
        }
    }

Upvotes: 0

Views: 295

Answers (0)

Related Questions