16,017,637 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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
Member 11392252
6-May-15 17:51pm
View
i created a table product and it has data in it. But my ques is i want to add the data from that product table into myproduct table by just entering the ProductID and not the other fields, how can i do this??
Show More