Erroe in ODBC Connection string in excel file import in .NET

I want to import excel data into my database using odbc and in .Net so i used this connection string:
OdbcConnection occon = new OdbcConnection
("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};
DBQ=" + path + ";

where DBQ path is set by the file path i want to ask is there a way i can write DSN details in the above connection string as it shows me error when my website is online and i have set a DSN of my sql server in System DSN in ODBC manager
The error that is shown is here


.OdbcException (0x80131937)
System.Data.Odbc.OdbcException (0x80131937): ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.Odbc.OdbcConnection.Open() at Common_TarrifPlans.btnUpload_Click(Object sender, EventArgs e)**

so after that i added a DSN to odbc manager
and after that it showed this error and dont know how to resolve it:


System.Data.Odbc.OdbcException (0x80131937): ERROR [HY000] [Microsoft][ODBC Excel Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x1db0 Thread 0x7dc DBC 0x78f8214 Excel'. ERROR [01S00]


0 answers