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
sunny kumar
NA
333
9.4k
Showing sql query results in json format
Aug 7 2019 1:00 AM
public
class
ValuesController : ApiController
{
Database_Access_layer.service db =
new
Database_Access_layer.service();
public
DataSet GetRecord()
{
DataSet ds = db.GetRecords();
return
ds;
}
public
class
service
{
string
st = ConfigurationManager.ConnectionStrings[
"connectionstring"
].ConnectionString;
public
DataSet GetRecords()
{
SqlConnection con =
new
SqlConnection(st);
string
adp =
""
;
adp = @"select s.State_Id, RTRIM(s.State_Name)
as
state_name,count(1)
as
totalNo
from BUyer_details
inner join Vehicles_Details vd on BUyer_details.Vehicles_Id=vd.Vehicles_Id
inner join Model_Registration mr on vd.Model_Code=mr.xEV_Model_Code
left outer join OEM_Registration om on BUyer_details.OEM_Id = om.OEM_Id
inner join Dealer_Registration dr on BUyer_details.Dealer_Id= dr.Dealer_Id
inner join Mst_Vehicle_Category vc on mr.Vihecle_cat_id=vc.Vihecle_cat_id
inner join tbl_MasterState s on dr.State_Id=s.State_Id
where 1=1 group by s.State_Name,s.State_Id order by State_Id asc";
SqlDataAdapter aa =
new
SqlDataAdapter(adp, con);
DataSet ds =
new
DataSet();
aa.Fill(ds);
return
ds;
}
}
I tried creating the query and then returning in json format, but it is showing collections, i want a single array
Reply
Answers (
2
)
How to may ways to handle exception in Entity Framework
Daily General Horoscopes