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
Abhilash J A
533
2.4k
598k
How to merge one DataTable to another DataTable in c#?
Oct 20 2016 10:52 PM
Hello Everyone,
I have two datatable from this query:-
string
sql =
"SELECT * FROM Tble_UserSetUp inner join Tble_Login on Tble_UserSetUp.Id = Tble_Login.UserId WHERE Tble_Login.UserId='"
+ Userid +
"';select count(*) as docCount from Tble_UserSetUp inner join Tble_Documents on Tble_Documents.UserId = Tble_UserSetUp.Id where Tble_Documents.UserId ='"
+ Userid +
"'"
;
DataTable dt =
new
DataTable();
DataTable dt1 =
new
DataTable();
da.Fill(ds);
dt = ds.Tables[0];
dt1 = ds.Tables[1];
dt
is getting all userdetails and
dt1
is getting only count.
How can I merge
dt1
inside
dt
? There is UserSetUp model class
contain int type
countID
, how to assign count value to
countID
variable
from
dt1
?
public
partial
class
UserSetUp
{
public
Int64 countID {
get
;
set
; }
}
var userList = from myRow
in
dt.AsEnumerable()
where myRow.Field<
bool
>(
"IsActive1"
) ==
true
select myRow;
List<Model.UserSetUp> objUserSetUp = userList.Select(m =>
new
Model.UserSetUp()
{
Id = m.Field<Int64>(
"Id"
),
FirstName = m.Field<
string
>(
"FirstName"
),
SurName = m.Field<
string
>(
"SurName"
),
Computer_Name = m.Field<
string
>(
"Computer_Name"
),
IP_Address = m.Field<
string
>(
"IP_Address"
),
LogInTime = m.Field<
string
>(
"LogInTime"
),
UserName = Decrypt(m.Field<
string
>(
"UserName"
)),
Password = Decrypt(m.Field<
string
>(
"Password"
)),
login_Id = m.Field<Int64>(
"login_Id"
),
UserType =
"Documents Scanned"
,
countID = ? /*
How can I assign dt1 value inside this variable?
*/
}).ToList();
Reply
Answers (
2
)
Adding to a string list XMLArrayItem using Get Set
Object reference not set to an instance of an object