Codice VBA su Excel per lanciare un comando SQL su un file Access

Codice VBA su Excel per lanciare un comando SQL su un file Access:


Const sProvider = "Microsoft.Jet.OLEDB.4.0"
Const sDb = "C:\database.mdb" ' settare percorso e nome file

Public Function sqlExecute(sSql)
Dim oConn As ADODB.Connection
Dim sConn As String
sConn = "Provider=" & sProvider & ";Data Source=" & sDb
Set oConn = CreateObject("ADODB.Connection")
oConn.ConnectionString = sConn
oConn.Open
Debug.Print sSql
oConn.Execute (sSql)
oConn.Close
Set oConn = Nothing
End Function



Esempio di utilizzo:
sqlExecute("INSERT INTO TABELLA (ID, COSTO) VALUES (1, 100)")

Tags: vba excel access lanciare comando sql da excel a access

I want to drink a coffee :-)


Sponsored Links


Ricerca


Ultimi Contenuti Inseriti

How to add onload property to masterpage from child
HtmlGenericControl body = (HtmlGeneric...

C# ASP.NET
...

Transpose Column to row
create table #temp (timeId int, dim1Id int, dim2I...

SQL Server
...

(X) HTML
Suggerimenti ed esempi riguardanti il linguaggio H...

Sponsor