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?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
In that case you just need something like:
"DSN=your_DSN_name,UID=username,Pwd=password;"

Open in new window

0
 
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
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)Connect With a Mentor 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 )Connect With a Mentor 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.