Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Record set versus data adapter
Message
De
22/02/2005 12:37:10
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows XP
Divers
Thread ID:
00989022
Message ID:
00989320
Vues:
26
Yuri,
I'm really confused about what's not working.
I don't know VB but wouldn't it be a & instead of + for concatenation? Quotes do match - sounds like there is an extra one before ExcelFile.
Cetin

>Cetin,
>
>The problem is not with the Adapter, it works. I would prefer to follow the existing working code in VB/VFP where ADO recordset is used. If it works there, then why it 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$]"
>....
>
>
>
>The error is:
>VB Error # 3001 was generated by ADODB.Recordset
>Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
>
>Cannot figure out why it works in VB and VFP, but does not work in VB NET, and what kind of arguments are not accepted.
>
>Any ideas of where to look into?
>
>
>>
>>Yuri,
>>Both versions are working for me:
>>
>>			string strSQL = "select * from [customer$]";
>>			string strCon = @"Provider=Microsoft.Jet.OLEDB.4.0;
>>  Data Source=c:\temp\customer.xls;
>>  Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
>>
>>//			OleDbConnection con = new OleDbConnection(strCon);
>>//			OleDbDataAdapter da = new OleDbDataAdapter(strSQL, con);
>>
>>			OleDbDataAdapter da = new OleDbDataAdapter(strSQL, strCon);
>>			DataSet ds = new DataSet();
>>			da.Fill(ds);
>>			foreach(DataRow dr in ds.Tables[0].Rows)
>>			{
>>				Console.WriteLine( "{0} {1}",dr["cust_id"], dr["contact"] );
>>			}
>>
>>
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform