| | |
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 .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic editvb.net employees excel exists fade filter forms html images isnumericfuntioncall listview map mobile module msaccess mssqlbackend mysql net number objects open pan panel pdf picturebox picturebox2 port position print printing printpreview record regex reuse right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver storedprocedure survey temp temperature textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms wpf wrapingcode xml year





