0

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?

  • Why do you need a DSN? – Caius Jard Nov 05 '21 at 18:57
  • You may want to clarify what you mean "Azure hosted environment" - code can run in Azure in all sort of configurations from functions (where you control almost nothing) to full VM (where you control everything including what OS to use). – Alexei Levenkov Nov 05 '21 at 19:28

1 Answers1

0

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

Utkarsh Pal
  • 4,079
  • 1
  • 5
  • 14