devxlogo

Accessing Database from Web Server

Accessing Database from Web Server

Question:

I have added a data connection in Visual Interdev. In the Data View I can see all my tables, fields and so on. My database resides on a SQL 7 server and my Web application is on the IIS 4 server. My problem is that I keep getting this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e4d' [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'SMIWEBIUSR_SMIWEB'. /Test/Page2.asp, line 24 

I have this code on my ASP:

Set oRs=Server.CreateObject("ADODB.Connection")oRs.Open Application("Connection1_ConnectionString"),Application("Connection1_RuntimeUserName"),Application("Connection1_RuntimePassword")	oRs.Execute ("Select * From tblDetail&qout;)

Answer:

This is one of the most common mistakes made by programmers.

When you are developing, you can see all the tables of a database because you have an ODBC DSN (Data Source Name) set up on your computer. This is set up so that Visual InterDev can see the database.

When your application is running from a Web Server Computer, it is looking for the YOUR computer's DSN on the Web Server Computer. When it does not find one, it fails. You need to set up the same DSN on the Web Server computer. Test the DSN when you have created it to make sure the database can be accessed succesfully.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist