Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
13
Reply
load data table to array
Dinesh Santhalingam
Dec 26 2016 4:56 AM
367
Reply
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;
}
}
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
13
)
Next Recommended Forum
load data table content into an array
How to Deployment ASP.NET (Web App) on IIS Server with SQL ?