Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
Data table to array and return array
Dinesh Santhalingam
8y
371
1
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