I have a ADO code that work very well without issues. But when I tried to convert it to DAO, it does not work. Here is the code sample.
It's giving me an error "3146 - ODBC - call failed"
The connection string work fine in ADO and the SQL syntax is correct as well.
Anyone can see why it failed?
Code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
strSQL = "CREATE LOGIN test WITH PASSWORD = xxx;"
Set db = CurrentDb
Set qdf = db.CreateQueryDef("")
qdf.Connect = "ODBC;DRIVER=SQL Native Client;SERVER=test\sqlexpress;DATABASE=myDB; " _
& "Trusted_Connection=No;Persist Security Info = True;UID=xxx;PWD=xxx"
qdf.ReturnsRecords = False
qdf.SQL = strSQL
qdf.Execute dbFailOnError
It's giving me an error "3146 - ODBC - call failed"
The connection string work fine in ADO and the SQL syntax is correct as well.
Anyone can see why it failed?