🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #3825

[?] Stringa SQL per Legere Sheet Di Excel con ADO.

#3825
From: Massimo
Date: Sun, 10 Mar 2002 06:48
37 lines
2546 bytes
Salve a tutti ,spero che qualcuno/a mi posso aiutare su questo problema:
Voglio creare un recordset da un foglio di Excel utilizando ADO per entrare
mi conetto atraverso un DSN previamente creato.
Entro nel file senza problema posso leggere la struttura del file grazie ad
ADOX pero quando ricavo il nome del foglio e lo uso nella stringa SQL ricevo
un errore perche il nome del foglio si porta il simbolo $ attacato al nome e
quindi mi da un errore de sintassi nella clausola FROM.
se sostituisco il nome del  "foglio$" con il nome del "foglio" continua
mandandomi un errore dicedo che non esiste l'ogetto "foglio"
Spero che qualcuno mi possa Aiutare e grazie
Massimo Commendatore

'Referencia ADO 2.7
'Referencia ADO Ext.Dll 2.7
Option Explicit

0        Dim cn As New ADODB.Connection
1        Dim rs As New ADODB.Recordset
2        Dim ver As New ADOX.Catalog
3        Dim tb As ADOX.Table
4        Dim fl As ADOX.Column
5        Dim strSQL As String
6        'Premessa uso questo codice perche ho solamente un foglio
7        Private Sub Form_Load()
8        cn.ConnectionString = "DSN=Mylog.xls"
9        cn.Open
10      Set ver.ActiveConnection = cn
11      For Each tb In ver.Tables
12      List1.AddItem tb.Name
13      strSQL = "SELECT * FROM " & tb.Name ' se eliminate questa linea e la
14 appare tutto nell List1
14      rs.Open strSQL, cn
15      For Each fl In tb.Columns
16      List1.AddItem fl.Name
17      Next
18     Next
19    End Sub
Technical Details
Message-ID: <a6eroa$1dv$1@newsreader.mailgate.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!212.177.105.133!news.mailgate.org!newsreader.mailgate.org!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ITALIAN,ASCII-7-bit
X-Google-Thread: f94ee,c5e64c14c70fd642,start
X-Google-Attributes: gidf94ee,public
X-Google-ArrivalTime: 2002-03-09 21:42:36 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!212.177.105.133!news.mailgate.org!newsreader.mailgate.org!not-for-mail
From: "Massimo" <la_scala26@hotmail.com>
Newsgroups: free.it.visual-basic
Subject: [?] Stringa SQL per Legere Sheet Di Excel con ADO.
Date: Sun, 10 Mar 2002 00:48:14 -0600
Organization: Mailgate.ORG Server - http://www.Mailgate.ORG
Lines: 44
Sender: la_scala26@hotmail.com
Message-ID: <a6eroa$1dv$1@newsreader.mailgate.org>
NNTP-Posting-Host: 206.128.203.80
X-Trace: newsreader.mailgate.org 1015738954 1471 206.128.203.80 (10 Mar 2002 05:42:34 GMT)
X-Complaints-To: abuse@mailgate.org
NNTP-Posting-Date: Sun, 10 Mar 2002 05:42:34 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200