Avatar of ygnd
ygnd
Flag for Israel asked on

excel vba connect to sql server 2005 express

Hello to the team again.
When I'm Using excel VBA to load sql server 2005 express data from tables that populate manually, with Management Studio Express. It works fine.
When I added new DB and populate it with my tables from access, using ODBC. it's not work.
I 'm getting an error "invalid object name 'dbo.Items' (my table from access).
Please advice.
Thank you,
Yalon
Microsoft SQL Server 2005Microsoft Excel

Avatar of undefined
Last Comment
ygnd

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
CSLARSEN

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ygnd

ASKER
Yes, with the change of db name.
strConn = "PROVIDER=SQLOLEDB;"
strConn = strConn & "DATA SOURCE=LepTop-2\SQLExPRESS;"
strConn = strConn & "Initial Catalog=WizPlan.V6;"
strConn = strConn & "Trusted_Connection=Yes;"
Dim DBcn As ADODB.Connection
Set DBcn = New ADODB.Connection
DBcn.Open strConn
sSQL = ""
sSQL = sSQL & "SELECT * FROM bdo.Items;"
Dim rst As ADODB.Recordset
Set rst = DBcn.Execute(sSQL)
ygnd

ASKER
I'm using dbo.Items
ygnd

ASKER
Done.
It ok.
I hade Miss write of the table name.
Thank you
Yalon
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
CSLARSEN

ok great,
so you manage to grab data from access with the above connection string?
cheers
cslarsen
ygnd

ASKER
I have an Excel application that using date from access which I'm now converting to sql server 2005 express.
With your help, it is already runing from the sql.
But I still have some more question comming ahead.
I exported tables from access to sql, using export method in the access through ODBC connection.
I found your service, very effective.
Thank you.
Yalon