| | |
Compare 2 Tables - Return Rows VB 2008
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2007
Posts: 45
Reputation:
Solved Threads: 1
Hows it going everyone. Im trying to compare two tables, and display the rows that are not in both tables in a DataGrid. Im using Visual Basic 2008, and created a query in the TableAdapterManager, but when I try to call the query, it is not displaying the results. Shows an error to lessen constraints, but I disabled constraints. I would really appreciate any tips, Im still pretty new to VB. Heres what I have in the query.
VB.NET Syntax (Toggle Plain Text)
SELECT Table1.Path, Table1.Filename, Table1.Type, Table1.[key], Table2.Path AS Expr1, Table2.Filename AS Expr2, Table2.Type AS Expr3 FROM Table1, Table2 WHERE (Table1.Path <> Table2.Path) OR (Table1.Filename <> Table2.Filename)
•
•
Join Date: Jun 2007
Posts: 22
Reputation:
Solved Threads: 5
Do you want to
1) step throgh all rows of Table1, and show the row when there is no row with the same path AND filename in Table 2
2) and then do the same vice versa?
If yes, and DBMS is MS SQL Server or Oracle I would use a union:
1) step throgh all rows of Table1, and show the row when there is no row with the same path AND filename in Table 2
2) and then do the same vice versa?
If yes, and DBMS is MS SQL Server or Oracle I would use a union:
VB.NET Syntax (Toggle Plain Text)
/* paste this in MS Query Analyzer, use || instead of + for oracle */ DROP TABLE t1 DROP TABLE t2 CREATE TABLE t1( sPath VARCHAR(20), sFilename VARCHAR(10) ) CREATE TABLE t2( sPath VARCHAR(20), sFilename VARCHAR(10) ) INSERT INTO t1 VALUES ( 'P1', 'F1' ) INSERT INTO t1 VALUES ( 'P2', 'F2' ) INSERT INTO t2 VALUES ( 'P1', 'F1' ) INSERT INTO t2 VALUES ( 'P3', 'F3' ) SELECT sPath + sFilename FROM t1 WHERE spath + sfilename NOT IN (SELECT spath + sfilename FROM t2) UNION ALL SELECT sPath + sFilename FROM t2 WHERE spath + sfilename NOT IN (SELECT spath + sfilename FROM t1) ------------------------------ P2F2 P3F3 (2 rows affected)
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: enter key
- Next Thread: Help StreamReader with DataGrid XML
| Thread Tools | Search this Thread |
.net 2005 2008 access account arithmetic array arrays basic bing button buttons c# center check checkbox code combobox component convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog folder ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output passingparameters peertopeervideostreaming picturebox picturebox1 port print printing problem problemwithinstallation project remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer toolbox trim update updown user validation vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





