Problem when connecting SQL through ADO

ben5000
Member Posts: 110
Hi experts,
I need to connect an external SQL database from NAV so I decided to use ADO 6.0 Automation.
I've already googled for it but didn't find relevant entries...
Here is the code I use to accomplish this (example from NAV Programming Cookbook):
When executing the CodeUnit I get the following error message:

I've checked both parameter of the ConnectionString and everything seems to be OK.
Here is the entry I get in the Event viewer (where SQL is running):
It seems to be a problem with the password. I've tried to connect other databases on other servers and the problem remains the same.
It's quite weird since the password is correct (I can connect through SSMS with those credentials)...
Thanks for your help
I need to connect an external SQL database from NAV so I decided to use ADO 6.0 Automation.
I've already googled for it but didn't find relevant entries...
Here is the code I use to accomplish this (example from NAV Programming Cookbook):
OnRun() CREATE(ADOConnection); ADOConnection.ConnectionString := CreateConnectionString( 'BTE219365', 'Demo Database NAV (6-0)', 'MANAGER', '12345678'); MESSAGE(ADOConnection.ConnectionString); ADOConnection.Open; CREATE(ADOCommand); ActiveADOConnection := ADOConnection; ADOCommand.ActiveConnection := ActiveADOConnection; ADOCommand.CommandText := 'SELECT [Name] FROM [Company$Customer] WHERE [No_] = ''10000'''; ADOCommand.Execute ; CREATE(ADORecordSet); ADORecordSet.ActiveConnection := ActiveADOConnection; ADORecordSet.Open(ADOCommand); WHILE NOT ADORecordSet.EOF DO BEGIN MESSAGE(FORMAT(ADORecordSet.Fields.Item('No_').Value)); END; ADOConnection.Close; CreateConnectionString(ServerName : Text[50];DatabaseName : Text[50];UserName : Text[50];Password : Text[50]) : Text[1024] EXIT ('Driver={SQL Server};' + 'Server=' + ServerName + ';' + 'Database=' + DatabaseName + ';' + 'Uid=' + UserName + ' ; ' + 'Pwd=' + Password + ' ; ')
When executing the CodeUnit I get the following error message:
I've checked both parameter of the ConnectionString and everything seems to be OK.
Here is the entry I get in the Event viewer (where SQL is running):
Log Name: Application Source: MSSQLSERVER Date: 15/05/2012 09:06:36 Event ID: 18456 Task Category: Logon Level: Information Keywords: Classic,Audit Failure User: N/A Computer: BTE219365.iuser.iroot.adidom.com Description: Login failed for user 'MANAGER '. Reason: Password did not match that for the login provided. [CLIENT: <named pipe>] Event Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="MSSQLSERVER" /> <EventID Qualifiers="49152">18456</EventID> <Level>0</Level> <Task>4</Task> <Keywords>0x90000000000000</Keywords> <TimeCreated SystemTime="2012-05-15T07:06:36.000000000Z" /> <EventRecordID>19002</EventRecordID> <Channel>Application</Channel> <Computer>BTE219365.iuser.iroot.adidom.com</Computer> <Security /> </System> <EventData> <Data>MANAGER </Data> <Data> Reason: Password did not match that for the login provided.</Data> <Data> [CLIENT: <named pipe>]</Data> <Binary>184800000E0000000A0000004200540045003200310039003300360035000000070000006D00610073007400650072000000</Binary> </EventData> </Event>
It seems to be a problem with the password. I've tried to connect other databases on other servers and the problem remains the same.
It's quite weird since the password is correct (I can connect through SSMS with those credentials)...
Thanks for your help

0
Answers
-
Here is a example too
http://dynamicsuser.net/blogs/waldo/archive/2008/01/06/using-stored-procedures-in-c-side.aspx
There are some spaces in like' + Password + '0 -
Thanks for your reply,
It was indeed a space in the connection string (the one after the password parameter) that caused parsing problems. And thus was not recognized as a valid password
Thanks for your help0 -
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions