locked
HOW TO INSERT AND UPDATE IMAGE TO SQL CE DATABASE USING WEBMATRIX RRS feed

  • Question

  • User-1557173817 posted

    HELLO PLEASE HOW CAN I INSERT AND UPDATE IMAGE TO SQL CE DATABASE AM USING WEBMATRIX

    Tuesday, August 25, 2015 5:05 AM

All replies

  • Tuesday, August 25, 2015 5:13 AM
  • User-1557173817 posted
    thanks but i was able to insert the filename and image path the database but the problem is to update it: here is my code;
     var imagePath="";
        var newFileName="";
      WebImage photo=null;
    
     


    photo=WebImage.GetImageFromRequest(); if(photo !=null) { newFileName=Guid.NewGuid().ToString() + "_" + Path.GetFileName(photo.FileName); imagePath=@"Photos\" + newFileName; photo.Save(@"~\" + imagePath);
    }
    if(Validation.IsValid()){
            var db = Database.Open("StarterSite");
    var updateCommand = "UPDATE patient SET imagePath=@0, newFileName=@1";
    db.Execute(updateCommand, image, newFileName);

    html:
                               <label>Upload a Photo : </label>
                        <input type="file" name="imagePath" />
                        <br></br>
                        <div style="padding: 10px;">
                        @if (imagePath !="" )
                        {
                           <img src="../@imagePath" alt="photo" width="150px" height="150px" />
                        }
                        
                        
                        </div>

    but its not udating with the new photo
    Tuesday, August 25, 2015 6:30 AM