connection-string

How to write a Proper SQL Connection String?

Using VB 6 and Sql Server 2000. In my code I am using open dialog control for selecting the database file, once I selected the database(Dual_ACS.mdf) file, it will appear in the textbox (path and filename) Textbox name = databasetext My code. Cn.ConnectionString = "Provider=SQLOLEDB.1; Persist Security Info=False;User ID=" & UName & ...

Connection string in unit test project to reference database in app_data folder

I am looking to reference my database file in my unit test project. This is an AP.NET MVC app. Please note: I know I should not be accessing the database in my unit tests but this is for a quick fix on one test that I need to have pass just now. After the next milestone I will be mocking the database access methods etc. So here is my ...

need help on ADO.net connection string

I have to get the data from a User site. If I would work on their site, I would VPN and then remote into their server using username and password. I thought getting data into my local machine than getting into their server where my work is not secured. So, I thought of using Ironpython to get data from the remote server. So, I still V...

SQL Express connection string hell ASP.Net

SQL Express 2005 is running locally. I have a project written by another person running on the same machine. All I want to do is connect to it, can't be that hard right? This is the one I use in my old classic ASP code to hit another database running on the same instance: Provider=SQLOLEDB;Data Source=MYLAPTOP\MSSMLBIZ;Persist Security...

Why couldn't I check for a null reference on a connection string?

Probably a C# noob question, so don't flame me. I was trying to do this: if (ConfigurationManager.ConnectionStrings["PrimaryConnectionString"].ConnectionString != null) { // ... } But I kept getting a System.NullReferenceException. I thought since it returns a string that I could just check for null and move on. It took me a while...

Storing connection strings in machine.config vs storing them in web.config

For a dedicated server, is it better to store the connection string in web.config or machine.config? what's the advantages and disadvantages of each approach? Thanks Edit: I'm concerned about security here, so, the question is about which approach is more secure. ...

Avoiding memory leaks while mutating c-strings

For educational purposes, I am using cstrings in some test programs. I would like to shorten strings with a placeholder such as "...". That is, "Quite a long string" will become "Quite a lo..." if my maximum length is set to 13. Further, I do not want to destroy the original string - the shortened string therefore has to be a copy. The...

Linq to Sql - Set connection string dynamically based on environment variable

I need to set my connection string for Linq to Sql based on an environment variable. I have a function which will return the connection string from the web.config based on the environment variable, but how do I get Linq to always use this "dynamically created" connection string (preferably without having to specify it every time)? I kn...

How are OLE DB connection strings mapped to DLLs?

How does the OleDbConnection constructor know what provider DLL (I assume it's a DLL) to call for a given provider name in the connection string? For example, in the following code... string cnStr = "Provider=Sybase.ASEOLEDBProvider.2;Server Name=etc..."; OleDbConnection cn = new OleDbConnection(cnStr); How does OleDbConnection know w...

Recommended ways to create a new database from an ASP.Net application

Our ASP.Net application uses SQL Server 2008. Most of the time the application connects to SQL Server using a SQL account with very limited access rights. However once in a while we need to be able to create a new database on the fly. As such we need elevated permissions and I am a little nervous about storing this connection string in...

ASP.Net configuration file -> Connection strings for multiple developers and deployment servers

I have a team of three developers, two of whom use a standard local test database, one of whom uses his own database and there is also a server environment with a production database and a testing database. This amounts to multiple connection strings required. The web.config file periodically gets updated and keeps having to be changed...

Dynamic Connection with SubSonic 3.0

Hi , I am building a asp.net application and I need to specify a different database for different types of users. Of course the schema is same for all databases. I want to be able to specify a dynamic connection string / provider once the user logs in and keep that for the session. How do it go about doing this. I have seen the earli...

Connection Lifetime=0 in MySql connection string

What exactly does Connection Lifetime=0 mean in a connection string? ...

WPF/C# - test connection string and fail elegantly

I've got a WPF application that uses LINQ to SQL DataContexts. What's a "best practice" way of testing the database connection and letting the user know that the connection is either bad or the network is down, etc, so that the app doesn't just bomb. Right now, I get the Splash Screen and then a "Program has stopped working" while "Win...

Sybase IQ and Encrypted Passwords

I have need to use the ENP (Encrypted Password) parameter with Sybase IQ. The documentation has a good reference on how to use it but not how to generate the password ... so how does one generate the encrypted password for use with the ENP connection parameter?? Thanks in advance ...

What's wrong with this ASP connection string?

I'm at the end of my rope on this. It should be so simple. I just need to know what's wrong with this connection string: dbc.open ("Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; " "User ID = Username; Password = Password;") I get this error when running that line: [Microsoft][ODBC Driver Manager] Da...

SQL Server 2005 SQL Authentication Connection String

Hello, I'm building an application that connects to SQL Server 2005. It currently uses Windows authentication, but I'd like to switch to SQL Authentication (I believe it is also sometimes called Mixed Authentication). My current connection string is: "Data Source=LOCALHOST;Initial Catalog={0};Integrated Security=SSPI" That's for Windo...

PowerShell update connection strings

Hi Everyone, I have the following script that will update the connection string across three different config files used in development. function Main() { pushd cd .. $aomsDir = pwd $configFiles = @( 'util\GeneratePocos.exe.config', 'src\Web.UI\web.config', 'src\Data\App.Config') $MyAOMSEntitiesConnStr = $env:AOMS_CONN_STR Write-...

SubSonic 2.1 using multiple databases

Hello, I want to use SubSonic 2.1 to connect to 2 different databases (each having different tables). What is the best way to do this? What is the best way to seperate the generated code between the 2 databases and how can I switch between databases? ...

Attaching catalog with SQL Authentication credentials attaches it as Read-Only

Hello, As part of our product's installation process, a database is attached to the server. We use EXEC sp_attach_db in order to attach it to MSSQL. The problem occures when we try to attach it with "SQL Authentication" connection string - the database is attached to the server as read-only, thus preventing any write access from being ...