0
I have a project in Excel where I am trying to make a connection to SQL Server database. I am working on a virtual machine and the database is on another machine, however they are all on the network, I have checked the IP of the machine where the database is and it is accessible from the virtual machine, but every time I try to make the connection to the database in VBA it fails.
and me Returns the following error;
[DBNETLIB] [Connectionopen(Connect()). ] SQL Server missing or denied access
below is my code!
Private Sub RoundRect2_Click()
Dim Cn As ADODB.Connection
Dim Server_Name As String
Dim Database_Name As String
Dim User_ID As String
Dim Password As String
Dim SQLStr As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Server_Name = "192.168.120.152:49172" ' Enter your server name here
Database_Name = "teste" ' Enter your database name here
User_ID = "root" ' enter your user ID here
Password = "1234" ' Enter your password here
SQLStr = "SELECT * FROM cod" ' Enter your SQL here
Set Cn = New ADODB.Connection
Cn.Open "Provider=SQLOLEDB;Server=" & Server_Name & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
rs.Open SQLStr, Cn, adOpenStatic
End Sub
And the mistake that is?
– Jorge Costa
[DBNETLIB] [Connectionopen(Connect()). ] SQL Server missing or access denied
– Leonardo
by chance where your bank is you have already given proper security permissions?
– wallafe sousa
I believe so, because I am connected in it by Datagrip
– Leonardo
The IDE connects normal but if you don’t give the proper permissions to the database where it is rarely will be able to use by applications!
– wallafe sousa