ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   From excel connect to SQl (https://www.excelbanter.com/excel-programming/330357-excel-connect-sql.html)

Alvin Hansen[_2_]

From excel connect to SQl
 
Hi

I try from excel to connect a SQL server
I try to use Server.Createobject("ADODB.Connection")

Can't i use this in excel or is it because i shall install some Tools/Ref

Best regards Alvin


Rob Bovey

From excel connect to SQl
 
"Alvin Hansen" wrote in message
...
I try from excel to connect a SQL server
I try to use Server.Createobject("ADODB.Connection")

Can't i use this in excel or is it because i shall install some Tools/Ref


Hi Alvin,

It looks like you copied that from some ASP code. There is no Server
object in Excel VBA, so change it to just:

CreateObject("ADODB.Connection")

and it should work fine in Excel.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm



Alvin Hansen[_2_]

From excel connect to SQl
 
Thanks

Alvin


"Rob Bovey" skrev:

"Alvin Hansen" wrote in message
...
I try from excel to connect a SQL server
I try to use Server.Createobject("ADODB.Connection")

Can't i use this in excel or is it because i shall install some Tools/Ref


Hi Alvin,

It looks like you copied that from some ASP code. There is no Server
object in Excel VBA, so change it to just:

CreateObject("ADODB.Connection")

and it should work fine in Excel.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm





All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com