0

Hi I cant seem to understand what's the problem here I keep getting this error message I tried using the debugger but it seems like its all working the way its supposed to but still it doesn't work here's the code

protected void btnSave_Click(object sender, EventArgs e)
{
    newsParagraf n = new newsParagraf();
    n.headTitle = txtHeader.Text;
    n.Article = txtArticle.Text;
    n.vids = txtVidLink.Text;

    string photoName = "";
    string extension = "";

    if (FuPhoto.HasFile)
    {
        photoName = Guid.NewGuid().ToString();
        extension = System.IO.Path.GetExtension(FuPhoto.PostedFile.FileName);
    }
    else
    {
        photoName = "Default";
        extension = "jpg";
    }
    string fileName = photoName + "." + extension;
    n.img = fileName;
    db.newsParagrafs.Add(n);
    db.SaveChanges();
    FuPhoto.SaveAs(Server.MapPath("~/images/" + fileName))
    txtArticle.Text = string.Empty;
    txtHeader.Text = string.Empty;
    txtVidLink.Text = string.Empty;
    Search();
    mvArtical.ActiveViewIndex = 0;
}

please help me am using entity framework on webforms

  • 2
    Please have a try catch around your code, and iterate through validation errors as described [here](https://stackoverflow.com/a/7798264/4636715). Then, share the details. That would be extremely useful. – vahdet Jul 04 '18 at 18:12
  • Its simple , please check length of character you are inserting in db. Match datatype and length of colum. – Asif Raza Jul 04 '18 at 18:23
  • I'm sorry but thats not helping – Osama Elayan Jul 04 '18 at 20:10

0 Answers0