Search Results

Search found 711 results on 29 pages for 'connectionstring'.

Page 1/29 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Specify Linq To SQL ConnectionString explicitly

    - by Michael Freidgeim
    When modifying Linq to  Sql data model in Visual Studio 2010,  it re-assigns ConnectionString that is available on developer’s machine. Because the name can be different on different machines, Designer often replace it with something like ConnectionString1, which causes errors during deployment.It requires developers to ensure that ConnectionString stays unchanged.  More reliable way is to use context constructor with explicit ConnectionString name instead of parameterless default constructor GOOD:   var ctx = new MyModelDataContext(Settings.Default.ConnectionString);Not good:          var ctx = new MyModelDataContext();

    Read the article

  • Understand Sql Server connectionstring for asp.net

    - by Eatdoku
    Hi, I am trying to understand the differences between the following 2 connectionstrings. one uses servername\instancename and the other one uses the server ip address. Can I specify port number for "serverName\instanceName". I know you can specify port number for ip address, something like '10.0.0.1,xxx'. thanks, Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True; Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

    Read the article

  • Change My.Settings ConnectionString in runtime?

    - by Sultanen
    I have a ClickOnce deployment where i have a INI-settings file on the network file with "global" settings that is supposed to affect the program on all client computers. The problem i have is that i whant to have the Database connectionString stored in this INI file and have it read and stored in the My.Settings ConnectionString at program startup. How do i do this? The ConnectionString setting is Application scoped and therefore Read-Only, if i try to set it by My.Settings("ConnectionString") = "Source=server;Initial Catalog=database;Integrated Security=True" I get a runtime error: An error occurred creating the form. See Exception.InnerException for details. The error is: The type initializer for 'DB_lib.DB_LINQ' threw an exception. [EDIT] I got rid of the error by using the My.Settings("ConnectionString") = "Source=server;Initial Catalog=database;Integrated Security=True" in another place then the the eventtriggerd settingsLoaded method i created.. The problem is that even though the connectionstring semes to be the right, the program still connects to the "default" database that is typed in to the app.config file??

    Read the article

  • ObjectContext ConnectionString Sqlite

    - by codegarten
    I need to connect to a database in Sqlite so i downloaded and installed System.Data.SQLite and with the designer dragged all my tables. The designer created a .cs file with public class Entities : ObjectContext and 3 constructors: 1st public Entities() : base("name=Entities", "Entities") this one load the connection string from App.config and works fine. App.config <connectionStrings> <add name="Entities" connectionString="metadata=res://*/Db.TracModel.csdl|res://*/Db.TracModel.ssdl|res://*/Db.TracModel.msl;provider=System.Data.SQLite;provider connection string=&quot;data source=C:\Users\Filipe\Desktop\trac.db&quot;" providerName="System.Data.EntityClient" /> </connectionStrings> 2nd public Entities(string connectionString) : base(connectionString, "Entities") 3rd public Entities(EntityConnection connection) : base(connection, "Entities") Here is the problem, i already tried n configuration, already used EntityConnectionStringBuilder to make the connection string with no luck. Can you please point me in the right direction!? EDIT(1) How can i construct a valid connection string?!

    Read the article

  • Make SubSonic use existing <connectionstring> instead of new data provider

    - by paolodm
    I am adding SubSonic to a legacy application. This application already defines a ConnectionString. Is there a way I can use this connectionstring instead of creating a new Data Provider entry? I know that one solution is programmatically setting this in the code (i.e. SubSonic.DataService.GetInstance("Name").SetDefaultConnectionString("ConnString") ). However, is there a more elegant solution?

    Read the article

  • Need help with ConnectionString value in C#

    - by SzamDev
    Hi I have an idea and I want to apply it to my Application (C# .NET). When we connect to a DB (MS SQL Server 2008) in VS 2008, the ConnectionString saved in the Application Setting and it's a static varriable (no one can edit it unless you edit it inside VS 2008). I want a way to let my Application search for MS SQL Server and save it to Application Setting and use it to connect to my DB Programmatically. When my application start, the first thing to do is checking the ConnectionString if vaild, NOT Empty and test connection to MS SQL Server Successfully so if there is a proplem I think to show a window form to let the user enter some data like username and password for MS SQL Server 2008 Is there any way to do it?

    Read the article

  • What is the differences between connectionstring and appsettings?

    - by n10i
    in one of the application i have been reffering connection string is stored in appsettings! till now i have been storeing the connection in <connectionstring/> element. But, what is the correct way? So my quetion is, What is the differences between <connectionstring> and <appsettings> in web.config, are there any specific reason why i should or should not be storing connection string in appsettings? Are there any rules / guidlines provided to follow? Or is this completely the choice of the developer?

    Read the article

  • .NET connecting to oracle problems with the connectionstring

    - by Oxymoron
    At the moment I'm trying to make a connection to a local server. Connecting via, say, TOAD works fine. When I try to connect using .NET I get ora-12154. Which puzzles me, since I'm using the connectionstring from my TNSNAMES.ora file: XE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myPC)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE) ) ) As follows: private string connectionString = "Data Source=(DESCRIPTION =" +" (ADDRESS_LIST=(ADDRESS = (PROTOCOL = TCP)(HOST = myPC)(PORT = 1521)))" +" (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE));" +"User Id=sys;Password=zsxyzabc;"; Any ideas?

    Read the article

  • How do I correctly use Unity to pass a ConnectionString to my repository classes?

    - by GenericTypeTea
    I've literally just started using the Unity Application Blocks Dependency Injection library from Microsoft, and I've come unstuck. This is my IoC class that'll handle the instantiation of my concrete classes to their interface types (so I don't have to keep called Resolve on the IoC container each time I want a repository in my controller): public class IoC { public static void Intialise(UnityConfigurationSection section, string connectionString) { _connectionString = connectionString; _container = new UnityContainer(); section.Configure(_container); } private static IUnityContainer _container; private static string _connectionString; public static IMovementRepository MovementRepository { get { return _container.Resolve<IMovementRepository>(); } } } So, the idea is that from my Controller, I can just do the following: _repository = IoC.MovementRepository; I am currently getting the error: Exception is: InvalidOperationException - The type String cannot be constructed. You must configure the container to supply this value. Now, I'm assuming this is because my mapped concrete implementation requires a single string parameter for its constructor. The concrete class is as follows: public sealed class MovementRepository : Repository, IMovementRepository { public MovementRepository(string connectionString) : base(connectionString) { } } Which inherits from: public abstract class Repository { public Repository(string connectionString) { _connectionString = connectionString; } public virtual string ConnectionString { get { return _connectionString; } } private readonly string _connectionString; } Now, am I doing this the correct way? Should I not have a constructor in my concrete implementation of a loosely coupled type? I.e. should I remove the constructor and just make the ConnectionString property a Get/Set so I can do the following: public static IMovementRepository MovementRepository { get { return _container.Resolve<IMovementRepository>( new ParameterOverrides { { "ConnectionString", _connectionString } }.OnType<IMovementRepository>() ); } } So, I basically wish to know how to get my connection string to my concrete type in the correct way that matches the IoC rules and keeps my Controller and concrete repositories loosely coupled so I can easily change the DataSource at a later date.

    Read the article

  • Relative path reference in WebConfig.ConnectionString

    - by Ngu Soon Hui
    Is it possible to specify a relative path reference in connectionstring, attachDbFileName property in a web.config? For example, In my database is located in the App_data folder, I can easily specify the AttachDBFilename as|DataDirectory|\mydb.mdf and the |Datadirectory| will automatically resolve to the correct path. Now, suppose that web.config file is located in A folder, but the database is located in B\App_data folder, where A and B folder is located in the same folder. Is there anyway to use relative path reference to resolve to the correct path?

    Read the article

  • SQL ConnectionString in global.asax overridden by web.config

    - by rlb.usa
    This is going to sound very odd, but I have a web.config like this: <connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Data Source=BACKUPDB;..." providerName="System.Data.SqlClient"/> </connectionStrings> And a global.asax like this: void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started if (Application["con"] == null || Application["con"] == "") { Application["con"] = "Data Source=PRODUCTIONDB;..."; } } And EVERYWHERE in my code, I reference my ConnectionStrings like this: SqlConnection con = new SqlConnection(Convert.ToString(HttpContext.Current.Application["con"])); However, I see that everything I do inside this application goes to BACKUP db instead of PRODUCTIONDB. What is going on, how could this happen, and why? It doesn't make any sense to me, and it got me into a lot of trouble. We use LocalSqlServer string for FormsAuthentication.

    Read the article

  • SQL ConnectionString in web.config and global.asax implications

    - by rlb.usa
    This is going to sound very odd, but I have a web.config like this: <connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Data Source=BACKUPDB;..." providerName="System.Data.SqlClient"/> </connectionStrings> And a global.asax like this: void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started if (Application["con"] == null || Application["con"] == "") { Application["con"] = "Data Source=PRODUCTIONDB;..."; } } And EVERYWHERE in my code, I reference my ConnectionStrings like this: SqlConnection con = new SqlConnection(Convert.ToString(HttpContext.Current.Application["con"])); However, I see that everything I do inside this application goes to BACKUP db instead of PRODUCTIONDB. What is going on, how could this happen, and why? It doesn't make any sense to me, and it got me into a lot of trouble. We use LocalSqlServer string for FormsAuthentication.

    Read the article

  • Choosing connectionstring in VB.NET application at startup

    - by MatsT
    I have a VB.NET application with a connection to an SQL Server 2003. On the server there are two databases, MyDatabase and MyDatabase_Test. What I would like to do is to show a dialog when the program starts that let's the user choose which database to use. My idea is to create a new form as the starup form that sets this property and then launches the main form. Currently the connectionstring is specified in the application config file. Best would be if I can specify two different connection strings in that file to choose from, but for now it is also acceptable with other solutions like hardcoding the two connectionstrings into the startup form.

    Read the article

  • C# connectionString encryption questions

    - by 5YrsLaterDBA
    I am learning how to encrypt the ConnectionString for our C# (3.5) Application. I read the .Net Framwork Developer Guide (http://msdn.microsoft.com/en-us/library/89211k9b(VS.80).aspx) about securing connection string. but not fully understand the contents. It says "The connection string can only be decrypted on the computer on which it was encrypted." We have a release machine which will build our application which will generate the OurApp.exe.config and then install it to many product machines. Is that meam we have to have this encryption process separated with our application and run it at individual product machine? We may use the "RSAProtectedConfigurationProvider". It mentioned we need encryption key for that provider. when and how we should provide the encryption key? thanks,

    Read the article

  • Switching from one connectionstring to another when moving from development to cloud

    - by Nancy Walker
    Hello, I am working on a cloud application. When I test out the application on my computer I want to have my connection string set as follows in ServiceConfiguration.cscfg: <Setting name="DataConnectionString" value="UseDevelopmentStorage=true" /> When I publish to the cloud I need to have it set as follows: <Setting name="DataConnectionString" value="DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=yyy" /> I keep going from one environment to the other and keep having to change the DataConnectionString. Is there a way that I can automate this? I looked around and can't see any examples but I'm sure some others have the same problem as me. Thanks, Nancy

    Read the article

  • SQLCe local db in temp- path in connectionstring?

    - by Petr
    Hi, I have SQL Ce db in my app, which is included in my app directory. While debugging its OK, but when published and run with setup.exe, it retrieves "file not found" in temporary directory the app is ran from. I would like to run from standard location, but I dont know how to change it. I am using this string: SqlCeConnection connection = new SqlCeConnection("Data Source=database.sdf;Persist Security Info=False;"); When I run setup.exe, the app never starts, stating that in its temporary directory the db file was not found. When I run app.exe, it works. I do not understand it...:( EDIT: I can see that in the VS project settings, there is connection string and there is "Data Source=|DataDirectory|\Database.sdf" The path should be something like local directory? Thanks!

    Read the article

  • Problem with connectionstring and entityframework

    - by Masna
    Hello, I have a database (sql 2008 mdf file), a class library project with an edmx file, created with the wizard. So the connection string is also made by the wizard. This project is on a teamfoundation server. I can use all the wizard made objects when coding. But when i run the program and I try to make an entityContainerName, the program crashes and gives this error: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. on this line: public TestEntities() : base("name=TestEntities", "TestEntities") How can I solve this problem or what am I doing wrong?

    Read the article

  • Change connection on the fly

    - by aron
    Hello, I have a SQL server with 50 databases. Each one has the exact same schema. I used the awesome Subsonic 2.2 create the DAL based on one of them. I need to loop though a list of database names and connect to each one and perform an update one at a time. If there a way to alter how subsonic uses the connection string. I believe I would need to store the connection string in memory that way it can keep changing. Is this possible? I tried doing a ConfigurationManager.ConnectionStrings["theConnStrName"].ConnectionString = updated-connection-string-here; .. but that did not work thanks!

    Read the article

  • Connection string problems on shared hosting with sql server 2005 express

    - by dagogo
    hi i have problem connecting to my db on a shared hosting, my host provider says they deployed sql 2005 express on their database and i prepared my connection string as follows to take advantage of sql express. \ the data source nae i used originally was ./SQLExpress but my host provider asked that i change it to local host, although with the former it didnt connect, but still with the change as indicated above the error still comes up on access to my default page. the error is as follows; Server Error in '/' Application. Invalid value for key 'attachdbfilename'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Invalid value for key 'attachdbfilename'. Source Error: Line 120: Public Function GetID(ByVal sLgaName As String) As Integer Line 121: Dim q As String = "Select PLID " & "From LGA " & "Where LGAName = " & "'" & sLgaName & "'" Line 122: Dim cn As New SqlConnection(Me.ConnectionString) Line 123: Dim cmd As New SqlCommand(q, cn) Line 124: ive read up a lot on the web and googled ma fingers numb on this, i have a deadline to deliver this project and having successfully built the app it frustrating for this to happen. pls help me.

    Read the article

  • Problem Registering a Generic Repository with Windsor IoC

    - by Robin
    I’m fairly new to IoC and perhaps my understanding of generics and inheritance is not strong enough for what I’m trying to do. You might find this to be a mess. I have a generic Repository base class: public class Repository<TEntity> where TEntity : class, IEntity { private Table<TEntity> EntityTable; private string _connectionString; private string _userName; public string UserName { get { return _userName; } set { _userName = value; } } public Repository() {} public Repository(string connectionString) { _connectionString = connectionString; EntityTable = (new DataContext(connectionString)).GetTable<TEntity>(); } public Repository(string connectionString, string userName) { _connectionString = connectionString; _userName = userName; EntityTable = (new DataContext(connectionString)).GetTable<TEntity>(); } // Data access methods ... ... } and a SqlClientRepository that inherits Repository: public class SqlClientRepository : Repository<Client> { private Table<Client> ClientTable; private string _connectionString; private string _userName; public SqlClientRepository() {} public SqlClientRepository(string connectionString) : base(connectionString) { _connectionString = connectionString; ClientTable = (new DataContext(connectionString)).GetTable<Client>(); } public SqlClientRepository(string connectionString, string userName) : base(connectionString, userName) { _connectionString = connectionString; _userName = userName; ClientTable = (new DataContext(connectionString)).GetTable<Client>(); } // data access methods unique to Client repository ... } The Repository class provides some generics methods like Save, Delete, etc, that I want all my repository derived classes to share. The TEntity parameter is constrained to the IEntity interface: public interface IEntity { int Id { get; set; } NameValueCollection GetSaveRuleViolations(); NameValueCollection GetDeleteRuleViolations(); } This allows the Repository class to reference these methods within its Save and Delete methods. Unit tests work fine on mock SqlClientRepository instances as well as live unit tests on the real database. However, in the MVC context: public class ClientController : Controller { private SqlClientRepository _clientRepository; public ClientController(SqlClientRepository clientRepository) { this._clientRepository = clientRepository; } public ClientController() { } // ViewResult methods ... ... } ... _clientRepository is always null. I’m using Windor Castle as an IoC container. Here is the configuration: <component id="ClientRepository" service="DomainModel.Concrete.Repository`1[[DomainModel.Entities.Client, DomainModel]], DomainModel" type="DomainModel.Concrete.SqlClientRepository, DomainModel" lifestyle="PerWebRequest"> <parameters> <connectionString>#{myConnStr}</connectionString> </parameters> </component> I’ve tried many variations in the Windsor configuration file. I suspect it’s more of a design flaw in the above code. As I'm looking over my code, it occurs to me that when registering components with an IoC container, perhaps service must always be an interface. Could this be it? Does anybody have a suggestion? Thanks in advance.

    Read the article

  • When to use "using [alias = ]class_or_namespace;" in c#?

    - by Pandiya Chendur
    I saw the following namespace implementation in an article and i really can't get the point why they did so? using sysConfig =System.Configuration ; string connectionString = sysConfig.ConfigurationManager. ConnectionStrings["connectionString"].ConnectionString; I know It can be easily implemented like this, string connectionString = System.Configuration.ConfigurationManager. ConnectionStrings["connectionString"].ConnectionString; Any suggestion when to use the first type...

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >