c# - OdbcConnection open() doesn't work -
protected odbcconnection conectarbd() { string stringdeconexion = "data source=pablozn\\sqlexpress;initial catalog=proyecto2;integrated security=true"; try { odbcconnection conexion = new odbcconnection(stringdeconexion); conexion.open(); return conexion; } catch (exception ex) { label3.text = ex.stacktrace.tostring(); return null; } }
the problem when browse website, label shows exception on line number 18:
en system.data.odbc.odbcconnection.handleerror(odbchandle hrhandle, retcode retcode) en system.data.odbc.odbcconnectionhandle..ctor(odbcconnection connection, odbcconnectionstring constr, odbcenvironmenthandle environmenthandle) en system.data.odbc.odbcconnectionopen..ctor(odbcconnection outerconnection, odbcconnectionstring connectionoptions) en system.data.odbc.odbcconnectionfactory.createconnection(dbconnectionoptions options, dbconnectionpoolkey poolkey, object poolgroupproviderinfo, dbconnectionpool pool, dbconnection owningobject) en system.data.providerbase.dbconnectionfactory.createconnection(dbconnectionoptions options, dbconnectionpoolkey poolkey, object poolgroupproviderinfo, dbconnectionpool pool, dbconnection owningconnection, dbconnectionoptions useroptions) en system.data.providerbase.dbconnectionfactory.createnonpooledconnection(dbconnection owningconnection, dbconnectionpoolgroup poolgroup, dbconnectionoptions useroptions) en system.data.providerbase.dbconnectionfactory.trygetconnection(dbconnection owningconnection, taskcompletionsource
1 retry, dbconnectionoptions useroptions, dbconnectioninternal oldconnection, dbconnectioninternal& connection) en system.data.providerbase.dbconnectioninternal.tryopenconnectioninternal(dbconnection outerconnection, dbconnectionfactory connectionfactory, taskcompletionsource
1 retry, dbconnectionoptions useroptions) en system.data.providerbase.dbconnectionclosed.tryopenconnection(dbconnection outerconnection, dbconnectionfactory connectionfactory, taskcompletionsource`1 retry, dbconnectionoptions useroptions) en system.data.providerbase.dbconnectioninternal.openconnection(dbconnection outerconnection, dbconnectionfactory connectionfactory) en system.data.odbc.odbcconnection.open() en index.conectarbd() en c:..\documents\visual studio 2012\websites\proyecto\index.aspx.cs:lĂnea 18
verify user has access database . how use trusted connection , verify current user has access database . if application web , make sure networkservice can connect database.
you can try configure connection string via dsn in windows odbc manager.
Comments
Post a Comment