locked
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified RRS feed

  • Question

  • User-1797368610 posted

    Hello,

    i am trying to host a asp.net application into one of the azure web server which is build on windows server 2019 data center. i am using odbc connection to connect with sql server within the application. Application is working fine when i am running through VS from my workstation (windows 10) with local sql server database using same odbc connection. Also its working fine on azure web server when i am running/debugging the application through visual studio but not working when i am accessing the application hosting by IIS. any idea what could be the issue?

    <add name="Newton" connectionString="DRIVER={ODBC Driver 13 for SQL Server};Server=test1;Database=manhattan;Uid=123;Pwd=123"/>

    Thanks in advanced!

    <add name="DBTS" connectionstring="DRIVER={ODBC Driver 13 for SQL Server};Server=hdcbentest1;Database=HRBADGEPRINT;Uid=hdcweb;Pwd=hdcweb"></add>

    Wednesday, January 13, 2021 10:21 PM

Answers

  • User475983607 posted

    For some reason still not working. i am using below code to get the current user identity. but some how its getting app pool identity which is IIS AppPool\\TestBadge. FYI, i am debugging the code from wwwroot to see why access denying.  please click below link to see its getting app pool identity.

    I'm guessing you forgot to enable Windows Authentication.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 14, 2021 7:49 PM

All replies

  • User475983607 posted

    This error (Google) means there is an issue with the DSN entry or the DSN entry is missing.  I assume the server address is incorrect.  Unfortunately, there is not much we can do as we do not know anything about your server.

    Standard ODBC Driver 13 for SQL Server connection strings.

    https://www.connectionstrings.com/microsoft-odbc-driver-13-for-sql-server/

    You can simply connect with Visual Studio or SSMS and get the connection string.  You can even create a DSN entry or a udl file to get the connection string.

    Wednesday, January 13, 2021 10:51 PM
  • User-1797368610 posted

    Thanks for reply. But question is, if i can access the database using same odbc connection from visual studio why not from IIS when residing there.

    Wednesday, January 13, 2021 11:37 PM
  • User475983607 posted

    Thanks for reply. But question is, if i can access the database using same odbc connection from visual studio why not from IIS when residing there.

    You have to realize the community cannot see your setup.  Is IIS and Visual Studio running on the same machine?  Have you tried anything from my last thread?

    Thursday, January 14, 2021 12:22 AM
  • User-1797368610 posted

    Thanks again. Yes, IIS and visual studio running on same server.

    Thursday, January 14, 2021 1:33 AM
  • User475983607 posted

    I use the "ODBC Driver 13 for SQL Server" and cannot reproduce this issue.  I setup a DSN entry and open a connection using the DSN name.  

    Thursday, January 14, 2021 11:48 AM
  • User-1797368610 posted

    Appreciated for your help. i think i was able to find out the issue. so in my code i am trying to get the current user name who is accessing the application. if he/she's userid exist in the database then allow them  to access the application. now problem is when i am running the application from IIS, it's not getting the userid who is in the database. As you can see in the code, its getting IIS APPPOOL\\TestBadge identity and its failing because there is no userid exist with this name in the database. now question is how can i get current user windows identity like domain\john.

    Click here to see the code

    Thanks in advanced!

    Thursday, January 14, 2021 4:30 PM
  • User475983607 posted

    The syntax to get the current user is...

    string username = User.Identity.Name;

    https://docs.microsoft.com/en-us/dotnet/api/system.web.httpcontext.user?view=netframework-4.8

    Thursday, January 14, 2021 4:43 PM
  • User-1797368610 posted

    For some reason still not working. i am using below code to get the current user identity. but some how its getting app pool identity which is IIS AppPool\\TestBadge. FYI, i am debugging the code from wwwroot to see why access denying.  please click below link to see its getting app pool identity.

    Click Here

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    using System.Data;
    using System.Security.Principal;
    using System.Web.Security;
    
    
    
    public partial class Home : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string userid, domname,
      
            domname = System.Web.HttpContext.Current.User.Identity.Name;
            userid = domname.Substring(domname.IndexOf(@"\") + 1);
            userid = userid.ToLower();
            Session["userid"] = userid;
    
            if (!Database
                .CheckForPermission(userid))
            {
               Response.Redirect("AccessDenied.aspx");
            }
            
    
            if (!IsPostBack)
            {
                Fill_Grid_Details();         
            }
    
        }
    
    
    
    
    
    

    Thursday, January 14, 2021 6:48 PM
  • User475983607 posted

    For some reason still not working. i am using below code to get the current user identity. but some how its getting app pool identity which is IIS AppPool\\TestBadge. FYI, i am debugging the code from wwwroot to see why access denying.  please click below link to see its getting app pool identity.

    I'm guessing you forgot to enable Windows Authentication.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 14, 2021 7:49 PM