Ankush Jassal

Ankush Jassal

  • NA
  • 10
  • 3.8k

Insert audio in sql server 2008

Mar 29 2015 4:18 AM
I am saving audio and other data in database using asp.net mvc 3 and entity framework but the problem i got is an run-time exception :-
 
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
 
Upload.csHtml:-
 
<div class="upload">
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Upload your song</legend>
<div class="upload_text">
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Email)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Country)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Country)
@Html.ValidationMessageFor(model => model.Country)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.State)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.State)
@Html.ValidationMessageFor(model => model.State)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.City)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.City)
@Html.ValidationMessageFor(model => model.City)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Song)
</div>
<div class="editor-field">
<input type="file" name="song" />
</div>
<div class="editor-label">
<select name="song type">
<option>-Select song type-</option>
<option>Old is Gold</option>
<option>Hindi songs</option>
<option>Punjabi songs</option>
<option>English songs</option>
</select>
</div>
<p>
<input type="submit" value="Create" />
</p>
</div>
</fieldset>
}
</div>
 
In Controller.cs:-
 
public ActionResult Upload(Upload_Song upload)
{
return View();
}
[HttpPost]
public ActionResult Upload(HttpPostedFile file)
{
Upload_Song upload = new Upload_Song();
ae.AddToUpload_Song(upload);
ae.SaveChanges();
if(upload.Song_type=="Punjabi")
{
if(file.ContentLength>0)
{
var filename=Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Media/Punjabi"),filename);
file.SaveAs(path);
}
ViewBag.Message = "Upload successfully";
return RedirectToAction("Index");
}
return View();
}
 Can anyone please help where i am wrong.

Answers (3)