Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > vb.net connection string question
 

vb.net connection string question

In a vb.net windows application, under "Settings" in the project propertie tab, I have 2 values for the "application settings", one dynamic with type set to "String" and the other value set to "(Connection string)". The Windows application is using the dynamic connection string, but during teh development I create the dataset using the "static" "Connection string", so that I can review data and also it is the only way I can create a dataset. My question is how to convert a static connection dataset to a dynamic connection for teh one created dataset. Thanks
pmak  Tuesday, July 28, 2009 9:45 PM
Hi pmak,

Please look at the following article.
http://gilbertadjin.wordpress.com/2009/04/02/connection-strings-in-vbnet/

It changes the "setting.vb" file and the returnConnectionString method will build the connection string. You can store some user name and password in the config file and let your user to select one. That one will be inuse. Use that one to build the connection string.

If I misunderstood something, please feel free to tell me.

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Thursday, July 30, 2009 7:51 AM
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Tuesday, August 04, 2009 8:08 AM

Suppose I had this in my config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="ConnString" providerName="System.Data.SqlClient"
connectionString="Data Source=MyServer;Initial Catalog=Northwind;Integrated Security=SSPI"/>
</connectionStrings>
<appSettings>
<add key="SupportPath" value="C:\Documents and Settings\john.grove" />
<add key="SupportEmail" value=somEmail@yahoo.com />
</appSettings>
</configuration>

Here is the difference on accessing them:
String supportPath = ConfigurationManager.AppSettings["SupportPath"];
String supportEmail = ConfigurationManager.AppSettings["SupportEmail"];
String connString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;


John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
JohnGrove  Tuesday, August 04, 2009 6:56 PM

You can use google to search for other answers

Custom Search

More Threads

• GetSelectedRow from Datagrid
• how to get bindingcontext/position from related child tabel
• fill the combobox with a field
• Protecting the appearance of an application form from changing
• connect a DataSet to a new database
• AutoGenerateColumns DataGridView
• Connect Sql server 2005 from Pocket Pc 2003
• ContextSwitchDeadlock Was Detected
• combobox?
• i need to keep the content of a .doc file in my rich text box control