Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Reply
Data table to array and return array
Dinesh Santhalingam
7 years ago
362
Reply
[System.Web.Services.WebMethod]
public void loaddata()
string
sql
=
"SELECT Name,Time,Inuse FROM table4"
;
using (SqlConnection
Connection
=
new
SqlConnection((@"Data Source)))
{
using (SqlCommand
myCommand
=
new
SqlCommand(sql, Connection))
{
Connection.Open();
using (SqlDataReader
myReader
=
myCommand
.ExecuteReader())
{
DataTable
dt
=
new
DataTable();
dt.Load(myReader);
Connection.Close();
DataView
dv
=
new
DataView(dt);
dv.RowFilter
= (("
Name
=
'ACVX'
"));
var
tableEnumerable
=
dv
.ToTable().AsEnumerable();
var
tableArray
=
tableEnumerable
.ToArray();
return tableArray ;//Error
}
}
}
}
I Want to load my datatable into an Var Array and Return the array .suggest some ideas to do my TASK..
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
datarow to array from data table
Window command creating a dynamic batch script