Re: Setting the Connectionstring of sqlconnection at design time

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Jose Valle wrote:
Hello all,

I have a question/problem that you maybe able to help me with...

I would like to set the connections string property of a sqlconnection object at design time to something other than a static string. Something like shared member of a class or possibly a value in a config file.

I need it at design time because design time behavoir of other controls on my form depend on a connection object with a configured connectionstring property.

I have tried setting up a connection via server explorer that allows me to use the dropdown on the connectionstring property to select it, however, all that does is pull in the generated connection string. this is a problem because If i need to make a change to the connection string later, I will have to manually search and replace thru out the application.

please let me know if I should clarify further.... :)
Any help/guidance is greatly appreciated.


-Jose



I would set a global string variable named myConnectionString (or something else that is self-explanatory) and reference that wherever you need it. If you need to change it, you only have to change it in one place.

--
Grant Smith
A+, Net+, MCP x 2

Quality Production Liaison
Hewlett Packard Company

Database Administrator
Renaissance Systems and Services, LLC
.



Relevant Pages

  • Re: [SOLVED] Cannot display provider-specific login prompt
    ... scenario where the program wouldn't have to know about the database, ... ConnectionStringBuilder up to a PropertyGrid for the end user to populate), ... details of the connection, for the sake of the program being able to connect ... information about the connection string that I will need. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Complicated Connection Problems bewteen ADP and SQL Server
    ... front end on the 5-8 workstations where the users happen to sit. ... expertise for getting the user workstations talking to the SQL Server. ... connection would fail and the adp wouldn't be able to talk to the server. ... thought that I should instead change my connection string to something ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Fujitsu NetCobol 8.0
    ... You cannot use a connection string in the way you have shown and expect it ... Any Fujitsu NetCobol / PowerCobol users here? ... Use the ADO control provided in PowerCOBOL, ...
    (comp.lang.cobol)
  • Re: Changing Connection String programmatically
    ... This is a good situation for putting the connection string information in the app.config file. ... every year we will create new database. ... change the body of the private void InitConnection(), ...
    (microsoft.public.sqlserver.connect)
  • Re: ASP.net and Oracle error System.Data.OleDb.OleDbException
    ... Also see http://www.connectionstrings.com/ and try other providers ... > Here is some of my connection code: ... >> And are you sure your connection string is ok. ... >>> Oracle error occurred, but error message could not be retrieved from ...
    (microsoft.public.dotnet.framework.aspnet)