Article View: free.it.visual-basic
Article #191Re: Vb6 e DB SQL
From: Reventlov
Date: Mon, 07 Jul 2008 19:21
Date: Mon, 07 Jul 2008 19:21
71 lines
3576 bytes
3576 bytes
Il giorno Mon, 7 Jul 2008 01:12:30 -0700 (PDT), Chicco <s.faccenda@gmail.com> ha scritto:
>1) C'=E8 un modo per sapere i campi di una tabella? Data la Tabella X
>voglio sapere quali campi ci sono.
>2) Se eseguo una StoreProcedure come posso sapere se ha finito?
>(SenzaParametri)
>3) Mi collego al DB di SQL con ODBC, esiste una stringa di connessione
>alternativa? Magari diretta?
Per la numero uno: questo vbs elenca le colonne di ogni tabella.
'*** Crea una finestra di IE per l'output ***
Set myIE = CreateObject("InternetExplorer.Application")
myIE.Navigate "about:blank"
myIE.ToolBar = true:myIE.StatusBar = False:myIE.Resizable = False
Do:Loop While myIE.Busy
myIE.Width = 600:myIE.Height = 400
myIE.Left = 50:myIE.Top = 50
myIE.Visible = True
myIE.document.writeln("<html><title></title>"&_
"<body><DIV id='cont'></DIV></body></html>")
Set IEWindow = myIE.Document.all("cont")
'**********************************************
Title= "Elenco tabelle e campi di un database - by Cenati Giovanni"
Set objArgs = WScript.Arguments 'Vedo se c'� un agrogmento passato allo script
if objargs.count<>1 then 'altrimenti mostro come si usa il programma
msgbox "Trascinare un file mdb sul programma per ottenere l'elenco dei
campi",vbInformation+vbOkonly,Title
myIE.quit
wscript.quit
end if
DbFile = objArgs(0) 'questa variabile contiene il nome del file da leggere
'Trovo il nome della directory in cui c'� questo programma.
'Percorso= left(wscript.scriptfullname, instrrev( wscript.ScriptFullName,"\"))
'DbFile= percorso & "northwindtables.mdb"
'Set oRecordset = createobject("ADODB.Recordset")
Set oConnection = createobject("ADODB.Connection")
oConnection.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbFile & ";"
'oRecordset.ActiveConnection = oConnection
Set cat = createobject ("adox.catalog")
cat.activeconnection= oConnection
Out="<h2><center>Database: " & DbFile & vbCrlf
out= out & "</center></h2><pre>"
For i=0 To cat.tables.count -1
out= out & "Tables(" & i & ")=" & cat.tables(i).name & vbTab
out= out & cat.tables(i).type & vbCrlf
For j=0 To cat.tables(i).columns.count -1
out= out & Vbtab & "Columns("& j & ")="
out= out & cat.tables(i).columns(j)
out= out & vbTab & cat.tables(i).columns(j).type
out= out & vbTab & cat.tables(i).columns(j).definedsize & vbCrlf
Next
Next
out= out & "</pre>"
Const adVarWChar = 202
Const adColNullable=2
Const adWChar = 130
IEWindow.INNERHTML = out
oConnection.close
wscript.quit
--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
Technical Details
Message-ID:
<48726cac.394625@powernews.libero.it>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.news.tin.it!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mailReferences:
<6c466c5e-64b2-4107-bfce-60e719db5d3e@m44g2000hsc.googlegroups.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.news.tin.it!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mail From: noone@no.void (Reventlov) Newsgroups: free.it.visual-basic Subject: Re: Vb6 e DB SQL Reply-To: Write.to.Reventlov at signature.below Message-ID: <48726cac.394625@powernews.libero.it> References: <6c466c5e-64b2-4107-bfce-60e719db5d3e@m44g2000hsc.googlegroups.com> X-Newsreader: Forte Free Agent 1.21/32.243 Lines: 71 Date: Mon, 07 Jul 2008 19:21:29 GMT NNTP-Posting-Host: 151.81.16.208 X-Complaints-To: abuse@libero.it X-Trace: twister1.libero.it 1215458489 151.81.16.208 (Mon, 07 Jul 2008 21:21:29 MET DST) NNTP-Posting-Date: Mon, 07 Jul 2008 21:21:29 MET DST Organization: [Infostrada]