connection-string

What is the best way to store connection string in .NET DLLs?

The application my team is currently developing has a DLL that is used to perform all database access. The application can not use a trusted connection because the database is behind a firewall and the domain server is not. So it appears that the connection string needs to have a DB username and password. The DLL currently has the dat...

SharePoint - Connection String dialog box during FeatureActivated event

Does anyone know if it is possible to display a prompt to a user/administrator when activating or installing a sharepoint feature? I am writing a custom webpart and it is connecting to a separate database, I would like to allow the administrator to select or type in a connection string when installing the .wsp file or activating the f...

Fast database access test from .Net

What would be a very fast way to determine if your connectionstring lets you connect to a database? Normally a connection attempt keeps the user waiting a long time before notifying the attempt was futile anyway... ...

[ADO.NET] What's the deal with |Pipe-delimited| variables in connection strings?

I know that |DataDirectory| will resolve to App_Data in an ASP.NET application but is that hard-coded or is there a generalized mechanism at work along the lines of %environment variables%? ...

Runtime Configuration in .Net (specifically the EntLib)

Hi All, I'm looking for a way to configure a DB connection at runtime; specifically using the Enterprise Library. I see that there's a *.Data.Configuration (or something close to this ... don't recall off the top of my head) assembly but am finding not much on the interwebs. Complicating matters is the fact that the API help is broken...

Prompt for Database Connection String

I would like to offer a database connection prompt to the user. I can build my own, but it would be nice if I can use something that somebody else has already built (maybe something built into Windows or a free library available on the Internet). Anybody know how to do this in .Net? EDIT: I found this and thought it was interesting: Sho...

OLEDBConnection.Open() generates 'Unspecified error'

I have an application that uploads an Excel .xls file to the file system, opens the file with an oledbconnection object using the .open() method on the object instance and then stores the data in a database. The upload and writing of the file to the file system works fine but I get an error when trying to open the file on our production...

Connectionstring error after encypted using aspnet_regiis.exe

I've encrypted the connectionstring in my web.config file using the steps in the link below: http://www.codeproject.com/KB/database/WebFarmConnStringsNet20.aspx However, whenever I call my application, it will give the following error: Failed to decrypt using provider 'CustomProvider'. Error message from the provider: The RSA ...

Point ADO.Net DataSet to different databases at runtime?

I have a large ADO.Net dataset and two database schemas (Oracle) with different constraints. The dataset will work with either schema, but I want to be able to tell the dataset which schema to use (via connection string) at runtime. Is that even possible? ...

How do you specify the port number in a oledb connection string to SQL server 2005?

Just found this out, so i am answering my own question :) Use a comma where you would normally use a colon. This can be a problem for named instances, as you seem to need to specify the port even if it is the default port 1433. Example: Provider=SQLOLEDB;Data Source=192.168.200.123,1433; Initial Catalog=Northwind; User Id=WebUser; Pas...

Is there a difference between (local), '.' and localhost?

I've used all three of these when making local programmatic connections to databases. Is there any real difference between them? ...

How can I connect to an Oracle database as SYS using an ADO connection string?

I am trying this: Provider=MSDASQL.1;Persist Security Info=False;User ID=sys;Password=pwd;Initial Catalog=DATABASE;Data Source=OdbcDataSource;DBA Privilege=SYSDBA But I get the error: [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed I'm using Delphi, but answers in any language are welcome. Clarification: I am ab...

C# Retrieving correct DbConnection object by connection string

I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string. Is there any inbuilt functionality to do this, or any 3rd party libraries to assist. We are not necessarily building this connection string, so we cann...

Are there any classes (or methods) that can create a formatted connection string, given a provider name and user id, password etc?

Eg. ConnectionDetails cd = new ConnectionDetails (); cd.ProviderName = "System.Data.OleDb"; cd.DataSource = "serverAddress"; cd.Catalog = "database"; cd.UserId = "userId"; cd.Password = "password"; string connectionString = cs.CreateConnectionString(); // Should return: // "Provider=SQLOLEDB;Data Source=serverAddress;Initial Catalog=da...

How do I set the login info for SQL Server 2008 in Entity Framework?

Okay I'm still learning the ropes with the Entity Framework and I came across one more small issue. When I create my Entity Model from the SQL Server 2008 database it warns me about saving the login information in the connection string in the config file. Initially I wasn't concerned about that so I just left it in there, but now I want...

SQL Reporting Services DataConnection Update

Is it possible to change the connection string of a published sql reporting services report? I can see the binary field called DataSource in the ReportServer database, but since it's stored as binary I don't think it's easily updatable. Do I need to republish the report with the correct data source? I'm hoping not since I do not want to...

Connect MS Access to SQL Server Compact database using ADO

I am trying to connect to a SQL Server Compact edition db (.sdf) from Access 2003. Here's the start of my code: Const sdfPath = "C:\SSCE\AmphiData.sdf" Dim pConn as ADODB.Connection Set pConn = new ADODB.Connection pConn.ConnectionString = "PROVIDER=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source = " & sdfPath pConn.Open The Open com...

Abstracting data connection layers and presentation layers in an enterprise application

We are building an enterprise application in which we will incorporate multiple platforms for user interfaces (i.e. ASP.net webapp, Windows Application, and someday, Mobile Apps) and multiple platforms for back-end databases (i.e. SQL Server, XML, Oracle). An additional neccesity is that these back-end DBs either be centralized and acce...

Connection string hell in .NET / LINQ-SQL / ASP.NET

I have a web application that comprises the following: A web project (with a web.config file containing a connection string - but no data access code in the web project) A data access project that uses LINQ-SQL classes to provide entities to the web project UI (this project has a settings file and an app.config - both of which have con...

Where does ConfigurationManager ConnectionStrings get its value?

In my ASP.NET application I have a web.config file. In the web.config file I have a connection string... <connectionStrings> <add name="HRDb" connectionString="xxxxx" providerName="System.Data.SqlClient" /> </connectionStrings> Yet, when I retrieve this value using ConfigurationManager.ConnectionStringsp["HRDb"], I get the my old ...