I current have an Excel that is built to query off an SQL server. Where I am stuck is access to the server required a login. When the query runs, and the user hasn't entered the username/password, its coming up with a prompt. I'm trying to figure out how the first step I can do it have VBA automatically log in since the people who are going to be using this won't know the login detail. Looking around, I've found:
It seems simple enough but when I try to run it, I'm getting run-time error 424, object required. I believe it has something to do with oConn not being declared as anything but I'm not sure what to set it as.
Any ideas?
Code:
Sub sql_login()
oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=MyDatabase;" & _
"Uid=MyUserID;" & _
"Pwd=MyPassword"
End Sub
It seems simple enough but when I try to run it, I'm getting run-time error 424, object required. I believe it has something to do with oConn not being declared as anything but I'm not sure what to set it as.
Any ideas?