Skip to content
Loading
How to Store Data into a table of SQL in MVC without model
@Html.ValidationSummary()


@* @Html.ActionLink("Create", "Create", "property")*@
@* *@
@* *@
}
and my controller method is
public ActionResult SaveRecords()
{
String connectionString = "Data Source=ASPKCO-DANISH\\SQLEXPRESS1;Initial Catalog=PakeezaSodagran;Integrated Security=True;";
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand comm = new SqlCommand("insert into PropertyPosts(title) values(" + Request.QueryString["title"], conn);
try
{
comm.ExecuteNonQuery();
// Request.QueryString["text"] = null;
}
catch (Exception)
{
// MessageBox.Show("Not Saved");
}
finally
{
conn.Close();
}
return View();
}
 
  • Manas Mohapatra
     Follow below link that may help you:
     
    http://stackoverflow.com/questions/13162819/adding-additional-parameter-to-form-submit 
     
    Note: If it doesn't resolve your problem provide the sample how you are submitting the form.
  • Property Title
    @Html.TextBox("title", null, new { @class = "form-control valid", @data_val = "true", @data_val_required = " Property Title is required" })
     
    here is my code
    SqlCommand comm = new SqlCommand("insert into PropertyPosts(title) values(" + Request.QueryString["title"], conn);
     
    this always gets null even in textbox i am typing something like "sdfsdf" 
  • I want to get the textbox value in my code  behind file , i have to use Text box instead of hidden field or other .
  • Salman Beg
    You can use hidden field or use a session and can use that same in controller.thanks.