connection string name

R

Ryan Liu

Hi,

When i add a connection string FpConnStr from application setting UI in VS
2008, it ends with sth. like:

<connectionStrings>
<clear />
<add name="CapiInterviewer.Properties.Settings.FpConnStr"
connectionString="data source=PowerCapiData"
providerName="System.Data.SQLite" />
</connectionStrings>


Because this config is also shared by other class library/projects for the
same application/solution, I don't like the
"CapiInterviewer.Properties.Settings" part VS 2008 added for me, is there
any way to avoid it without breaking code? For example, I also use VS 2008
data design to add a DataSet file (*.xsd), who will uses this connection
string.

Thanks a lot!
Ryan
 
J

Joe Fawcett

Ryan Liu said:
Hi,

When i add a connection string FpConnStr from application setting UI in
VS 2008, it ends with sth. like:

<connectionStrings>
<clear />
<add name="CapiInterviewer.Properties.Settings.FpConnStr"
connectionString="data source=PowerCapiData"
providerName="System.Data.SQLite" />
</connectionStrings>


Because this config is also shared by other class library/projects for the
same application/solution, I don't like the
"CapiInterviewer.Properties.Settings" part VS 2008 added for me, is there
any way to avoid it without breaking code? For example, I also use VS 2008
data design to add a DataSet file (*.xsd), who will uses this connection
string.

Thanks a lot!
Ryan
Just change the name value before using the connection. When asked to choose
a connection for a task later the new value will be used.
If the config file is shared across apps then you may want to consider
removing the clear element.
 
R

Ryan Liu

Thanks Joe, but ...

Joe Fawcett said:
Just change the name value before using the connection. When asked to
choose a connection for a task later the new value will be used.
If the config file is shared across apps then you may want to consider
removing the clear element.


If I just change name, then Design.setting.cs won't work. Seems it always
use short name to match "long" name in app.exe.config file.




 
J

Jeff Winn

The reason that is being stored that way is you probably used the designer
to place a control on the form that needed a connection string, or you're
using the Settings section of the project to manipulate your app.config
file. If you don't want to have the name look like that, edit your
app.config file within your project manually, and set the connection strings
within your application when you need them.

You won't have that point and click ability to add designer controls to your
form, but i hate using those anyway. Also imo, DataSets tend to be overused
when working with databases. Keep an eye on how much memory your application
is using since that type stores all of the data in memory - depending on the
size of your table they can get very large and start to slow your
application down.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top