TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mark Tabor
548
2k
460.4k
show details of the selected record
Sep 25 2016 3:13 AM
I have a simple website in mvc , i am new to mvc i have services in that first view and i have a read more button with each service to show the service details when i click the read more button i want to show the details of that service below is my service class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
namespace BusinessApplicationTemplate.Models
{
public class Service
{
public List<Service> Getdatabyid(int id)
{
String connectionString = "Data Source=ASPKCO-DANISH\\SQLEXPRESS1234;Initial Catalog=PakeezaSodagran;Integrated Security=True;";
String sql = "SELECT * FROM Service where ID = "+ id;
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
var model = new List<Service>();
while (rdr.Read())
{
var service = new Service();
service.ID = Convert.ToInt32(rdr["ID"]);
service.Name = rdr["Name"].ToString();
service.Description = rdr["Description"].ToString();
service.Image = rdr["Image"].ToString();
model.Add(service);
}
return model;
}
}
}
}
Can any one give me the example it would be much easier for me to follow
Reply
Answers (
2
)
How can create session in SQL/MySql.
WebForm vs WebApi how to pass data between them