Click here to Skip to main content
16,017,637 members

Comments by Member 11392252 (Top 6 by date)

Member 11392252 14-Dec-15 7:47am View    
I'm trying to session but I don't know how to use it.
Member 11392252 27-Nov-15 5:19am View    
I've already tried this..... and then posted here.....
Member 11392252 6-Oct-15 9:06am View    
<add name="ADO_mvc" connectionstring="Data source=.\sqlexpress; Initial Catalog=ADO_mvc; Integrated Security=true ">
This is my Connection string.
Member 11392252 6-Oct-15 8:33am View    
In SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["con_String"].ToString());
(Here)
Member 11392252 6-Oct-15 8:26am View    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ADO_MVC.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

return View();
}
public ActionResult InsertResult()
{
ADO_MVC.Models.Info data = new Models.Info();
data.Fname = Request["fname"];
data.Lname = Request["lname"];

int res = data.Insert();
if(res>0)
{
Response.Write("Insert Successfull....");

}
else
{
return RedirectToAction("Index", "Home");
}
return View();
}

public ActionResult About()
{
ViewBag.Message = "Your app description page.";

return View();
}

public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
}
}
This is the HomeController

@model ADO_MVC.Models.Info
@{
ViewBag.Title = "InsertResult";
}

InsertResult


<html>
<body>
@using (Html.BeginForm("InsertResult", "Home"))
{
<fieldset>
My Information
<table>
<tr>
<td>@Html.LabelFor(model => model.ID)</td>
<td>@Html.TextBox("id")</td>
</tr>
<tr>
<td>@Html.LabelFor(model => model.Fname)</td>
<td>@Html.TextBox("fname")</td>
</tr>
<tr>
<td>@Html.LabelFor(model => model.Lname)</td>
<td>@Html.TextBox("lname")</td>
</tr>
<tr>
<td>@Html.TextBox("btn_submit", "Insert Data", new { type = "submit" })</td>
</tr>
</table>
</fieldset>
}

</body>
</html>
This is the Index Page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ADO_MVC.Models
{
public class Info
{
public int ID { get; set; }
public string Fname { get; set; }
public string Lname { get; set; }

public int Insert(Info data)
{
string query = "insert into myinfo values('"+data.Fname+"','"+data.Lname+"')";
ADOMVC ado = new ADOMVC();
int res = ado.Insert(query);
return res;
}
public int Insert()
{
string query = "insert into myinfo values('" + Fname + "','" + Lname + "')";
ADOMVC ado = new ADOMVC();
int res = ado.Insert(query);
return res;
}


}

}
And this is the Model Info.cs