Sunday, 4 March 2012

Steps for generating connection string in .NET 3.5

1)Create new website using following screenshot:







2)But make sure that whether your backend language is vb or c# by selecting language from combo box shown below:

3)After selecting backend language ,click on ok button.
4)Now go to Solution Explorer, right click on the path as shown below and click on Add New Item:

5)After clicking on Add new Item, Following window appears  from this window select sql server database, type the name of database in Name: text Box and click on Add Button.

6)After clicking on Add button ,following Message Box appears.See deafult location of your database is App_Data folder which is present inside your project folder.So click on Yes button when following message box comes.

7)Now after completing above step following screen appears.Now you can see Database Explorer on right side of this screen.Database Explorer shows all database related file.

8)Now right click on Tables in Database explorer and click on Add New Table:

9)After clicking on Add New Table following window appears ,In Column Name type all attribute name of your table then select datatype for that attribute from next column and check or uncheck check box as per your requirement.


10)Now click on save button to save your table,choose Name window asks you the name of table then click on OK button.

11)Now go to .aspx page,go to tool box from Data tab select SqlDataSource on .aspx page as shown below.

 12)You can see a smart tag on right side of this control click on this smart tag then click on configure data source link as shown below.

 13)After above step following window appears ,click on New Connection botton.



14)After clicking on New Connection, choose data source(Microsoft Sql Server Database File ) as shown below then click on ok button:
15)After clicking on ok button ,Add Connection window appears as shown below .Now click on browse button and  browse your databaseDefault location of your database is location where your visual studio is installed.Eg.C:\Documents and Settings\ITSURE\My Documents\Visual Studio 2008\WebSites\WebSite5\App_Data


16)Now click on Test Connection Button after clicking Connection succeeded message box appears.

17)After clicking on OK button following window appears click on Next Button.

18)Click on Next button moves you to a following window which gives you the connection string.Default generated connection string is name of your database appended with ConnectionString words(in our case it is DatabaseConnectionString).

19)At this stage you can change your such big connection string with smaller one as shown below:

20)Click on Next Button opens following window then click on * check box.


21)Again click on Next button which opens following window now click on Test Query button.

22)Click finish. This completes your all steps for generating connection string for database connection.If you forgot your connection string you can check it from web config file present in solution explorer.in following snapshot you can see thta connection string is "suresh".


No comments:

Post a Comment