Link to home
Start Free TrialLog in
Avatar of Ronald popo
Ronald popo

asked on

ADO Connection issue

Hi everyone,
I have a word template that merges data from a sql DB.  I did not write it.  The server crashed and a new server was installed.  I am having a connection problem.  It is a template that was written prior to 2005.

This is part of the code concerning the connection

Public drive As New ADODB.Connection
Public cmd As New ADODB.Command
Public DOTainCntFlag As String

in addition:

Public Sub GetLPMain()
On Error GoTo Err_GetLDriving
Dim sqlstring As String
Dim lpmrs As New ADODB.Recordset
'
' Connects to database and gets Driversrecord
'

Customer_num = [custNumber]

' Set ADO connection
drive.Open "DSN=myserver-new-year\Drivers;uid=workers;pwd=checking;database=Driving"
Set cmd.ActiveConnection = drive

I'm getting the following error.  I've googled it and still the same

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Look at this and choose some of the options suitable for you:

https://www.connectionstrings.com/sql-server/




Sorry, you have to change your local ODBC DSN settings, not the connection string.


Open this Exe and look for your DSN Name and change the Config for your DSN entry:

C:\Windows\sysWOW64\odbcad32.exe



Also check if you do not have 64bit Windows this ODBC Manager to find your DSN entry:

C:\Windows\system32\odbcad32.exe




ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ronald popo
Ronald popo

ASKER

below is my string and I'm getting command failed error[

WordBasic.MailMergeMainDocumentType 0
WordBasic.MailMergeOpenDataSource Name:="", ConfirmConversions:=0, ReadOnly:=0, LinkToSource:=0, AddToMru:=0, PasswordDoc:="", PasswordDot:="", Revert:=0, WritePasswordDoc:="", WritePasswordDot:="", Connection:="Driver={SQL Server};Server=myserver-new-year\Drivers;UID=empnum1;PWD=;APP=Microsoft Query;WSID=myserver-new-year\Drivers;LANGUAGE=us_english;DATABASE=Driving", SQLStatement:="execute splp_empcust " & Chr(34) & custnumbers & Chr(34), SQLStatement1:=""
WordBasic.MailMerge CheckErrors:=1, Destination:=0, MergeRecords:=0, From:="", To:="", Suppression:=0, MailMerge:=1, MailSubject:="", MailAsAttachment:=0, MailAddress:=""

Please write more details here on EE.


Nobody can look at your script lines and guess what is your environment and what is going wrong without  error message details.


Therefor post here your complette error message and state whether you use ODBC DSN or now you try to connect without local ODBC manager.



Thank you gentlemen.  This original question is working.  Thanks again.