I have created a subdomain mapped to a sub - directory of the website. The default page of the sub directory (http://www.mydomain.com/foldername/default.asp) works fine, but shows error

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

The connection string is in global.asa
application("strconnectstring")="Provider=SQLNCLI;Data Source=.;Initial Catalog=mydb;User ID=XXXX;password=XXXXXX"

Can't figure out the problem
Any help?

Dani AI

Generated

's suggestion to confirm ASP/SQL is a good first check. Since reports those are enabled but the subdomain cannot read the Application connection string, the most common cause is an application-bound scope issue, not a missing SQL driver.

Classic ASP Application variables are scoped to an IIS application. If the subdomain was created as a separate site or as its own application in IIS, it will not inherit the parent site's Application state (global.asa). Common fixes:

  • Verify in IIS (or your hosting control panel) whether the subdomain is a separate site or a virtual directory under the main site. If it is a separate site, it needs its own global.asa or connection initialization.
  • If you want the same Application state, map the subdomain as a virtual directory inside the same IIS application, or convert the folder to an application only if you intend to initialize Application there.
  • Move the connection string out of an Application variable and into a shared include file that both hostnames include, or create a small global.asa in the subdomain root that sets the same Application key.
  • If on shared hosting, request the host set the subdomain to use the same application root or provide guidance about their mapping.

Quick diagnostic page to run under both URLs to confirm what the subdomain actually sees:

<%
Response.Write "Host: " & Request.ServerVariables("SERVER_NAME") & "<br>"
Response.Write "App physical root: " & Server.MapPath("/") & "<br>"
Dim cs : cs = Application("strconnectstring")
If Len(Trim(cs & "")) = 0 Then
  Response.Write "Application connection string is EMPTY"
Else
  Response.Write "Connection string present"
End If
%>

If that shows the connection string empty under the subdomain but present via the full www path, fix the IIS application mapping or add the initialization to the subdomain. If the string is present but you still get the ODBC error, check provider availability and 32/64-bit app pool settings.

Assuming that you are using IIS to create/manage the domains, are both enabled for ASP and SQL?

Yes, both enabled for asp and sql. Actually the subdomain is not able to read application variable in which the connection string is there

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.