Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Record set versus data adapter
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Record set versus data adapter
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows XP
Divers
Thread ID:
00989022
Message ID:
00989022
Vues:
66
What could be wrong with the following? It works in VFP and in VB, but does not work in VB.NET.
....
cnnExcel = CreateObject("adodb.Connection")
cnnExcel.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _
        '              Excelfile + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1';")

....
' Open recordsets
Dim rstExcel As ADODB.Recordset
rstExcel = New ADODB.Recordset
        With rstExcel
            .ActiveConnection = cnnExcel
            .CursorLocation = ADODB.CursorLocationEnum.adUseClient
            .CursorType = ADODB.CursorTypeEnum.adOpenStatic
            .LockType = ADODB.LockTypeEnum.adLockReadOnly

* the line below gives an error 
            .Source = "SELECT * from [Matched$]"
....
However DataAdapter works:
.....
Dim DSExcel As System.Data.DataSet
Dim ExcelAdapter As System.Data.OleDb.OleDbDataAdapter
Dim cnnExcel As System.Data.OleDb.OleDbConnection

        cnnExcel = New System.Data.OleDb.OleDbConnection( _
             "provider=Microsoft.Jet.OLEDB.4.0; " & _
            "data source=" & Excelfile & "; " & _
            "Extended Properties='Excel 8.0;HDR=YES;IMEX=1';")

        'Select the data from Sheet Matched of the workbook.
        ExcelAdapter = New System.Data.OleDb.OleDbDataAdapter( _
             "SELECT * from [Matched$]", cnnExcel)

        DSExcel = New System.Data.DataSet
        ExcelAdapter.Fill(DSExcel)
.....
ANy ideas?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform