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
Dinesh Santhalingam
NA
737
370.4k
load data table to array
Dec 26 2016 4:56 AM
I have a sql table .I want load my table content into a data table dt .Add my data table content into an array and my array(tablearray) into a dictionary (lst).At last i return my dictionary .Here my code .I don't know How to add my array into dictionary? please help me to solve this problem.
[System.Web.Services.WebMethod]
public static Dictionary
<
string
, object
>
Load()
{
string
sql
=
"SELECT Name,Marks FROM table4"
;
using (SqlConnection
Connection
=
newSqlConnection
((@"myconnstrng")))
{
using (SqlCommand
myCommand
=
new
SqlCommand(sql,Connection))
{
Connection.Open();
using (SqlDataReader
myReader
=
myCommand
.ExecuteReader())
{
DataTable
dt
=
new
DataTable();
dt.Load(myReader);
Connection.Close();
var
tableEnumerable
=
dt
.AsEnumerable();
var
tableArray
=
tableEnumerable
.ToArray();
Dictionary
<
string
, object
>
lst
=
new
Dictionary
<
string
, object
>
();
return lst;
}
}
}
}
Reply
Answers (
13
)
load data table content into an array
How to Deployment ASP.NET (Web App) on IIS Server with SQL ?