excelvbauserformsqloledb

Excel VBA Userform to SQLOLEDB Connection works Locally but not remotely - Run-time error '-2147467259 (80004005)': [DBNETLIB]


It's been a week of research now and I am still unable to fix this problem. I have created an Excel VBA User form that inserts data into an SQLOLEDB Connection (SQLEXPRESS 2017) when a CommandButton (Called "Save") is clicked. Locally (localhost) it works like a charm. All of the data from the columns gets inserted into the SQL DB Table successfully. No errors whatsoever.

However, when any client attempts to perform the same action I get the Run-time error '-2147467259 (80004005)': [DBNETLIB](ConnectionOpen (connect()).]SQL Server does not exist or access denied.

This is what I have tried so far:

This is the string I'm using to establish this connection:

conn.Open "Provider=SQLOLEDB;Data Source=PCNAME\SQLEXPRESS;Initial Catalog=DATABASENAME;Integrated Security=SSPI;Trusted_Connection=Yes"

conn.Execute "INSERT INTO dbo.TABLENAME (COLUMNNAME, COLUMNNAME2) values ('" & sColumnVariable & "', '" & sColumnVariable2 & "')"

My question will be:

How do I manage to allow clients to successfully insert into this SQL Database/Table?

Where does the problem lie? Does it lie within my Computers Settings? Does it lie within my Clients Computers Settings? Does it lie within my SQL Server Management Studio (maybe wrong/missing permissions)?

I appreciate your help in advance! Regards, Dave.


Solution

  • I was able to figure this out. It had to do with the IP. I used my Local Area Connection IP address ONLY, without \SQLEXPRESS along with a new user I created in SQL Server Management Studio in my connection string:

    conn.Open "Provider=SQLOLEDB;Data Source=IPADDRESS;Initial Catalog=DATABASENAME;Integrated Security=SSPI;User ID=MySQLTest;password=myPassc0de;

    I'm soooo happy.