I want to display the missing (non-matching) records
Is there a way to program the following SQL query
SELECT dbo.Assets_Master.Serial_Number, dbo.Assets_Master.Account_Ident, dbo.Assets_Master.Disposition_Ident
FROM 开发者_如何学JAVA dbo.Assets_Master LEFT OUTER JOIN
dbo.Assets ON dbo.Assets_Master.Serial_Number = dbo.Assets.Serial_Number
WHERE (dbo.Assets.Serial_Number IS NULL)
in c# .net code using dataviews or data relation or something else?
I have a spreadsheet of about 4k rows and a data table that should have the same records but if not I want to display the missing (non-matching) records from the table.
Thanks, Eric
If you've already got that query, you can just pass that text as a SQL command and pull back the results as a dataset. Better might be setting up your query as a stored procedure and then following the same steps (calling a stored proc is cleaner than writing the SQL by hand).
If you want a way to do it without SQL at all, you could use LINQ to grab an IENUMERABLE of your ASSETS_MASTER serial numbers and another IENUMBERABLE of your ASSETS records. Then something like:
foreach(ASSET asset in ASSETS) { if(!ASSETS_MASTER_SERIALSNOS.CONTAINS(asset.SerialNumber)) { //Do Whatever } }
精彩评论