Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27212

set primary key to existing dataset

$
0
0
Hi.

I have a database in access and some new data in excel.
I need to compare the two databases, updating the access with the new items and updating existing ones (and leaving others as they are because they do not appear in the excel file)
I populated a dataset from an xls file and now I need to set the primary key.

How do I do that?

Thanks

Code:

Dim ficheiroxls As String
        ficheiroxls = txtArquivos.Text
        Dim connectionxls As OleDbConnection
        Dim connectionxlsstring As String
        Dim sqlxls As String
        connectionxlsstring = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & ficheiroxls & "; Extended Properties=""Excel 8.0;HDR=YES"";"
        sqlxls = "SELECT * FROM [Medicamentos(1)$]"
        connectionxls = New OleDbConnection(connectionxlsstring)
        Dim adapterxls As New OleDbDataAdapter(sqlxls, connectionxls)
        adapterxls.Fill(medicamentosxls)


Viewing all articles
Browse latest Browse all 27212