locked
save image path in database in asp.net RRS feed

  • Question

  • User186310208 posted

    hello..i am doing save path into database but i dnt know for what reasons its not saving..i also try break point..

    protected void btnSave_Click(object sender, EventArgs e)
    {
    Model.WallpaperCategory newusermodel = new Model.WallpaperCategory();
    string str = fileUpload1.FileName;
    fileUpload1.PostedFile.SaveAs(Server.MapPath("~/Upload/" + str));
    string Path = "~/Upload/" + str.ToString();
    newusermodel.Path = Path;
    newusermodel.Category = ddlWallCategry.SelectedItem.Value;
    using (var context = new WallpaperEntities11())
    {
    WallpaperRecord user = new WallpaperRecord
    {

    Path = Path,
    CreatedBy = DateTime.Now,
    UploadedBy = DateTime.Now,

    };
    {
    string path = fileUpload1.FileName;
    user.Path = newusermodel.Path;
    user.Category = ddlWallCategry.SelectedItem.Value;
    //var Category = newusermodel.Category;
    };

    var usersadd = context.Set<WallpaperRecord>();
    var response = context.WallpaperRecords.Where(u => u.Category == newusermodel.Category).FirstOrDefault();
    if (response == null)
    {
    usersadd.Add(user);
    context.SaveChanges();

    Monday, August 17, 2020 7:00 AM

Answers

  • User186310208 posted

    its done basically in query i m == opertors i just changed != its working

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 17, 2020 7:35 AM

All replies

  • User-821857111 posted

    Does context.SaveChanges get called? What was the value of response?

    Monday, August 17, 2020 7:14 AM
  • User186310208 posted

    Mikesdotnetting

    Yes...

    context.Savechanges() i working and also get the value

    problem when i try to save..it not getting any value

    Monday, August 17, 2020 7:17 AM
  • User186310208 posted

    its done basically in query i m == opertors i just changed != its working

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 17, 2020 7:35 AM