Unable to establish ODBC connection using PHP

Noji
Member Posts: 2
Please forgve my newbie-ness, if I have posted this in the wrong forum (I couldn't tell by the names which applies) or whether I am asking an old or redundant question.
We have Navision 2009 (Nav 6?) running on a Windows Server 2008 R2, and all our employees are running happily with it. Now, I need to create a web page that will allow anybody in the world to access (read-only) our Nav database by issuing a query, etc. The problem I'm having is that I can't seem to get the PHP call odbc_connect() to establish a connection. My complete connection code is as follows:
First, the server name "qdsql2\qdsql2" is actually correct. Second, yes, I specify the username and password redundantly, but that is acceptable, as far as I understand. The result is that odbc_connect returns zero (failure) every time, and I don't know why.
I have spent the past three days scouring your (and others') forums, etc, to find my answer, and two posts seem to come close, but both were dead-ends for me. Any hand-holding would be appreciated.
Thanks,
Noji Ratzlaff
Quartzdyne, Salt Lake City
We have Navision 2009 (Nav 6?) running on a Windows Server 2008 R2, and all our employees are running happily with it. Now, I need to create a web page that will allow anybody in the world to access (read-only) our Nav database by issuing a query, etc. The problem I'm having is that I can't seem to get the PHP call odbc_connect() to establish a connection. My complete connection code is as follows:
<?php $username = 'flooruser'; $password = 'flooruser'; $odbc = odbc_connect("Driver={SQL Server};Server=qdsql2\qdsql2;Trusted_Connection=yes;Database=QD6NAVSQL;Uid=flooruser;Pwd=flooruser;", $username, $password) or die('The server is currently unavailable'); ?> <html lang="eng"> . . . </html>
First, the server name "qdsql2\qdsql2" is actually correct. Second, yes, I specify the username and password redundantly, but that is acceptable, as far as I understand. The result is that odbc_connect returns zero (failure) every time, and I don't know why.
I have spent the past three days scouring your (and others') forums, etc, to find my answer, and two posts seem to come close, but both were dead-ends for me. Any hand-holding would be appreciated.
Thanks,
Noji Ratzlaff
Quartzdyne, Salt Lake City
0
Comments
-
[Topic moved from 'NAV Tips & Tricks' forum to 'SQL General' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Noji wrote:We have Navision 2009 (Nav 6?) running on a Windows Server 2008 R2, and all our employees are running happily with it.
Instead of querying the NAV database through ODBC, he uses NAV webservices to read the data. This requires the Service Tier to be installed, even is you are using the classic client instead of the Role Tailored Client. If your employees are using the RTC, then this Service Tier is already up and running.
I would give it a shot with this approach, as webservices are here to stay. And when the need is there to write data back into NAV, you have already the perfect framework for this, as all business logic will be executed as well (which you don't get when writing data to the database through ODBC).
Sorry for not being able to give you a working example of your code, but my experiences with PHP and database are limited to mySQL only, resulting in this code:$link = mysql_connect($dbhost, $dbuser, $dbpasswd); mysql_select_db($dbname, $link); $result = mysql_query("SELECT * FROM DatabaseTable"); if(!$result) die("Query Failed."); mysql_close($link);
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Instead of using a DSN-less connection, you could create a System DSN through the Data Source Name wizard ("Data Sources (ODBC)" in Windows 7): http://www.devasp.com/samples/dsn_sql.asp . A System DSN allows you to connect to a database server using an alias rather than writing out a long connection string.
The PHP-code to connect to the database will then look like this:$dsn="MyDSN"; $username = 'flooruser'; $password = 'flooruser'; $sqlconnect=odbc_connect($dsn,$username,$password);
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
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