Access Connection String



Right now I have this Connection string code in C#
using (

                  OleDbConnection conn =
                       new OleDbConnection(
                                "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Incoming Vehicles\\Square1_Inspection2.accdb;Persist Security Info=False;")
                //   "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\\\sq1server\\data\\QUALITY SYSTEM\\Incoming Vehicles\\Square1_Inspection2.accdb;Persist Security Info=False;")

                     )



WHat I need a connection String that uses a DSN called Square1. This DSN points to the same file..

Thank
LVL 8
Leo TorresSQL DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
In that case you just need something like:
"DSN=your_DSN_name,UID=username,Pwd=password;"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo TorresSQL DeveloperAuthor Commented:
Ok but where do I put it
0
Leo TorresSQL DeveloperAuthor Commented:
why would i need username if that info is in the DSN
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Leo TorresSQL DeveloperAuthor Commented:

                  OleDbConnection conn =
                       new OleDbConnection("DSN=Square1,UID=admin,Pwd=;")


Produces this error
System.ArgumentException: An OLE DB Provider was not specified in the ConnectionString.  An example would be, 'Provider=SQLOLEDB;'.
   at System.Data.OleDb.OleDbConnectionString.ValidateProvider(String progid)
   at System.Data.OleDb.OleDbConnectionString.ValidateConnectionString(String connectionString)
   at System.Data.OleDb.OleDbConnectionString..ctor(String connectionString, Boolean validate)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   at System.Data.OleDb.OleDbConnection.ConnectionString_Set(String value)
   at System.Data.OleDb.OleDbConnection.set_ConnectionString(String value)
   at System.Data.OleDb.OleDbConnection..ctor(String connectionString)
   at Square1WebService.Service1.Getmake(String CarMake) in C:\Users\ltorres\Documents\Visual Studio 2010\Projects\Odesk_Square1WebService\Square1WebService\Square1InfoPath.asmx.cs:line 809

0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<WHat I need a connection String that uses a DSN called Square1>>

 Why do you want to do this given that you can specify the string directly?  It's a hassel to create DSN's on a station.  That's why everyone is moving to DSN-less connection strings, which is what your already doing.

JimD.
0
Leo TorresSQL DeveloperAuthor Commented:
OK, I using this string
and it is generating this error

System.Exception: System.Data.OleDb.OleDbException: The Microsoft Office Access database engine cannot open or write to the file '\\sq1server\data\QUALITY SYSTEM\Incoming Vehicles\Square1_Inspection2.accdb'. It is already opened exclusively by another user, or you need permission to view and write its data.
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState&amp; originalState)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
   at Square1WebService.Service1.Getmake(String CarMake) in C:\Users\ltorres\Documents\Visual Studio 2010\Projects\Odesk_Square1WebService\Square1WebService\Square1InfoPath.asmx.cs:line 824
   at Square1WebService.Service1.Getmake(String CarMake) in C:\Users\ltorres\Documents\Visual Studio 2010\Projects\Odesk_Square1WebService\Square1WebService\Square1InfoPath.asmx.cs:line 852



I do not have file open. there is no ldb file in the folder that would sugguest the file is in use. I am the owner od that folder as I created and went into security and made sure I have full control of folder..

Iam gussing this issue is caused by the way the string is trying to connect to DB..

If Im wrong then great but I still need to find a way to connect to DB.. I decided to try DSN since I can open it in ODBC properties and adjust the connection type to DB..

Any advise on this would be greatly apreaciated




0
käµfm³d 👽Commented:
I decided to try DSN since I can open it in ODBC properties and adjust the connection type to DB..
If you're worried about it changing, then you would simply make it a configuration settings. I agree with JDettman--DSNs are a pain in the...

0
Leo TorresSQL DeveloperAuthor Commented:
Ok so what should my connection string Look like..
0
Leo TorresSQL DeveloperAuthor Commented:
yes i know the DSN is a pain

Now I got
System.Exception: System.Data.OleDb.OleDbException: Could not find installable ISAM.
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState&amp; originalState)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
   at Square1WebService.Service1.Getmake(String CarMake) in C:\Users\ltorres\Documents\Visual Studio 2010\Projects\Odesk_Square1WebService\Square1WebService\Square1InfoPath.asmx.cs:line 833
   at Square1WebService.Service1.Getmake(String CarMake) in C:\Users\ltorres\Documents\Visual Studio 2010\Projects\Odesk_Square1WebService\Square1WebService\Square1InfoPath.asmx.cs:line 861

0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
"Cannot find installable ISAM" often means you don't have the necessary connection drivers/libraries on the machine which is running this code (your workstation, if this is a desktop app, or the server, if this is a web-based app).
0
Leo TorresSQL DeveloperAuthor Commented:
this is a web service MDAC maybe? From what I see online can. How can I determine what version is running on my machine?
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
What connection string does your webservice expect? If the Webservice expects you to provide a connection string for a specific version, you must do so.

0
Leo TorresSQL DeveloperAuthor Commented:
Need to use oleDB.. I figured this hurdle now for the next 1. Which is a different topic
0
Leo TorresSQL DeveloperAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.