How to create DSN in Azure environment?

197 Views Asked by At

I'm trying to create a DSN on an Azure hosted environment using the following code:

    public static bool AddSystemDsn(string server, string database)
    {
        return SQLConfigDataSource((IntPtr)0,
            4, //4 = ODBC_ADD_SYS_DSN
           "SQL Server\0",
           $"SERVER={server}\0DSN={database}\0DATABASE= 
           {database}\0TRUSTED_CONNECTION=Yes\0ANSINPW=NO");
    }

It's returning False, but I'm not sure why. I wonder if there better code I should be using to make a DSN on an Azure environment?

1

There are 1 best solutions below

0
Utkarsh Pal On

This tutorial can help you to create a System DNS using ODBC driver on sql-server.