![]() ![]() Now build the solution and enter the server name and database. writing the connection string in config file XmlDoc.Load( ) įoreach ( XmlElement 圎lement in XmlDoc.DocumentElement) Public void updateConfigFile( string con) Write a new function updateConfigFile with the following code. Add "using System.Xml using System.Configuration " in the name space. MessageBox.Show( () + ".This is invalid connection", "Incorrect server/Database") ħ. SqlDataAdapter da = new SqlDataAdapter( "select * from employee",Db) In case of VS2010 comment the above line and use the below line ![]() SqlDataAdapter da = new SqlDataAdapter( "select * from employee") To check new connection string is working or not to refresh connection string each time else it will use previous connection stringĬonfigurationManager.RefreshSection( "connectionStrings") ĭb.ConnectionString = () StringBuilder Con = new StringBuilder( "Data Source=") Ĭon.Append( " Integrated Security=SSPI ") Constructing connection string from the inputs Add "using " in the namespace and write the following code in the buttonclick event. Add a dropdown below to populate a column from a table as shown below.Ħ. Now add two text boxes, two labels and a button in the form as shown below.ĥ. Add the following code in the connection string.Ĥ. (Path : Start -> All Programs -> Microsoft Visual Studio 2005-> Microsoft Visual Studio 2005)ģ. ![]() Open Visual Studio and create new a Windows application. This will be helpful for users to use any server and database during run time without the need to create any connection string before execution.ġ. Also if there are multiple servers and databases, the number of connection strings will be high and a user cannot add everything to the App.config file. This will help the user to switch connections during run time. #Make a mobile app on microsoft visual studio 2005 how to#This document explains how to configure a connection string at runtime for a Windows application using C#. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |