0

I want a button click event to do this:

can i use "UNMATCHED" keyword in the same SQL Statment using a UNION ?

pls help me with this!! table1 is my master Db and table2 is my work DB.. both have same columns expect that primary key in both tables is serial number..

I want to display all records in an excel spreadsheet but I want all those values in table2 which exist in table1 as bold and those which do not in plain text..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Final Database.mdb")

Dim cmd As New OleDbCommand

cmd = New OleDbCommand("select table2.MFG MATCH as 'DELL' or 'HP from table2,table1 where table1.MFG=table2.MFG", con)

con.Open()

Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)

Try

Dim ds As DataSet = New DataSet()

ds.Tables.Add("table2")

da.Fill(ds, "table2") // [B]i get error here.."[U]Ierrorinfo.getdescription.failed with E_FAIL(0X80004005)[/B]) [/U]
DataGridView2.DataSource = ds.Tables("table2").DefaultView

Finally

con.Close()

cmd = Nothing

da.Dispose()

con.Dispose()

End Try

End Sub

End Class
1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by kavithabhaskar
0

I tried changing the code.. i want to compare my table1 and table2. if any of the values in table2 exist in table1, the excel o/p has to have that value in bold.

please Assist

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Final Database.mdb")

        Dim con1 As OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\bashkark\Desktop\Book1.xls")

        Dim cmd As New OleDbCommand

        cmd = New OleDbCommand("select table2.MFG MATCH as 'DELL' or 'HP from table2,table1 where table1.MFG=table2.MFG UNION Select table2.MFG MATCH as 'DELL' or 'HP' from table2,table1 where table1.MFG <> table2.MFG ", con)

        con.Open()



        Dim ds As DataSet = New DataSet

        Dim str As String

        Dim icount As Integer


        Dim excel As Object

        Dim book As Object

        Dim sheet As Object

        excel = CreateObject("Excel.Application")

        sheet = book.worksheet(1)

        sheet.Range("A1").Value = "MFG"

        sheet.Range("B1").Value = "MAKE"

        sheet.range("C1").value = " GRAPHICSCARD"

        sheet.range("D1").value = "GRAPHICSVERSION"


       Dim cmd1 as New OleDbCommand =("SELECT * INTO [Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\bashkark\Desktop\Book1.xls].[Sheet1] FROM [table2]", con1) 

        cmd = New OleDbCommand(str, con)

        icount = cmd.ExecuteNonQuery

        sheet = Nothing
        book = Nothing
        excel.Quit()
        excel = Nothing




        con.Close()

        cmd = Nothing

        con.Dispose()


    End Sub
End Class

I want a button click event to do this:

can i use "UNMATCHED" keyword in the same SQL Statment using a UNION ?

pls help me with this!! table1 is my master Db and table2 is my work DB.. both have same columns expect that primary key in both tables is serial number..

I want to display all records in an excel spreadsheet but I want all those values in table2 which exist in table1 as bold and those which do not in plain text..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Final Database.mdb")

Dim cmd As New OleDbCommand

cmd = New OleDbCommand("select table2.MFG MATCH as 'DELL' or 'HP from table2,table1 where table1.MFG=table2.MFG", con)

con.Open()

Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)

Try

Dim ds As DataSet = New DataSet()

ds.Tables.Add("table2")

da.Fill(ds, "table2") // [B]i get error here.."[U]Ierrorinfo.getdescription.failed with E_FAIL(0X80004005)[/B]) [/U]
DataGridView2.DataSource = ds.Tables("table2").DefaultView

Finally

con.Close()

cmd = Nothing

da.Dispose()

con.Dispose()

End Try

End Sub

End Class
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.