Thursday, 26 April 2012

Reset password In ASPNET membership VB

Reset password In ASPNET membership VB





ResetPassword.aspx

 <h3> Retrieve Password</h3>
    <p><asp:Label ID="Msg" runat="server" ForeColor="maroon" /><br />
    </p> Username:
    <asp:TextBox ID="UsernameTextBox" Columns="30" runat="server" AutoPostBack="True" />
    <asp:RequiredFieldValidator ID="UsernameRequiredValidator" runat="server" ControlToValidate="UsernameTextBox"
        ForeColor="red" Display="Static" ErrorMessage="Required" /><br />
    <asp:Button ID="ResetPasswordButton" Text="Reset Password" OnClick="ResetPassword_OnClick" runat="server" Enabled="False" />
    <br />
    <asp:Label ID="lblPassword" runat="server" ForeColor="maroon" Style="font-weight: 700;
        color: #FF0000; font-size: x-large" /><br />


ResetPassword.aspx.vb

Imports System.Web.Security

Public Class ResetPassword
    Inherits System.Web.UI.Page

    Dim u As MembershipUser

    Public Sub Page_Load(sender As Object, args As EventArgs) Handles Me.Load

        If Not Membership.EnablePasswordReset Then
            FormsAuthentication.RedirectToLoginPage()
        End If

        Msg.Text = ""

        If Not IsPostBack Then
            Msg.Text = "Please supply a username."
        Else
            VerifyUsername()
        End If
    End Sub

    Public Sub VerifyUsername()
        u = Membership.GetUser(UsernameTextBox.Text, False)

        If u Is Nothing Then
            Msg.Text = "Username " & Server.HtmlEncode(UsernameTextBox.Text) & " not found. Please check the value and re-enter."

            ResetPasswordButton.Enabled = False
        Else
            ResetPasswordButton.Enabled = True
        End If
    End Sub

    Protected Sub ResetPassword_OnClick(sender As Object, args As EventArgs) Handles ResetPasswordButton.Click
        Dim newPassword As String
        u = Membership.GetUser(UsernameTextBox.Text, False)

        If u Is Nothing Then
            Msg.Text = "Username " & Server.HtmlEncode(UsernameTextBox.Text) & " not found. Please check the value and re-enter."
            Return
        End If

        Try
            newPassword = u.ResetPassword()
        Catch e As MembershipPasswordException
            Msg.Text = "Invalid password answer. Please re-enter and try again."
            Return
        Catch e As Exception
            Msg.Text = e.Message
            Return
        End Try

        If Not newPassword Is Nothing Then
            Msg.Text = "Password reset. Your new password is: "
            lblPassword.Text = "" & Server.HtmlEncode(newPassword)
        Else
            Msg.Text = "Password reset failed. Please re-enter your values and try again."
        End If
    End Sub

End Class

Friday, 6 April 2012

Using a Custom Action to Create a Database at Installation

Note: 1. This walkthrough requires SQL Server on the computer where you will deploy the application.
2.The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu.
3.The following instructions demonstrate creating a deployment project using a Visual Basic project; the general principles apply to all Visual Studio language projects that support deploying Windows-based applications.

To create an installer class

  1. On the File menu, click New Project.
  2. In the New Project dialog box, select Visual Basic Projects in the Project Type pane, and then choose Class Library in the Templates pane. In the Name box, type DBCustomAction.
  3. On the Project menu, click Add New Item.
  4. In the Add New Item dialog box, choose Installer Class. In the Name box, type VbDeployInstaller.vb.

To create a data connection object

  1. In Server Explorer, select Data Connections. Right-click and choose Add Connection.
  2. In the Choose Data Source dialog box, select Microsoft SQL Server.
  3. In the Add Connection dialog box, do the following:
    1. In the Server name drop-down list, type or select a server name.
    2. Select Use Windows Authentication.
    3. In the database box, type master.
    4. Click OK to close the dialog box.
  4. From the Data menu, click Add New Data Source, then use the wizard to add the connection that you established in the previous steps. To verify that the data source is in the project, click Show Data Sources on the Data menu.

To create a text file that contains a SQL statement to create a database

  1. In Solution Explorer, select the DBCustomAction project. On the Project menu, choose Add New Item.
  2. In the Add New Item dialog box, choose Text File. In the Name box, type sql.txt (must be in lower case).
  3. Add the following to the sql.txt file:
    ------------------------------------------------------------------------------------------------------------
    CREATE TABLE [dbo].[Employees] (
    [Name] [char] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [Rsvp] [int] NULL ,
    [Requests] [nvarchar] (4000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
    ) ON [PRIMARY];
    
    ALTER TABLE [dbo].[Employees] WITH NOCHECK ADD 
    CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED 
    (
    [Name]
    ) ON [PRIMARY];
    ------------------------------------------------------------------------ 
  4. In Solution Explorer, select sql.txt. In the Properties window, set the BuildAction property to Embedded Resource.

To add code to the installer class to read the text file

  1. In Solution Explorer, select VbDeployInstaller.vb. On the View menu, choose Code.
  2. Add the following Imports statement at the top of the module:

Imports System.IO
Imports System.Reflection
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports System.Configuration.Install
Public Class VbDeployInstaller Dim masterConnection As New System.Data.SqlClient.SqlConnection()
Public Sub New() MyBase.New() 'This call is required by the Component Designer.
InitializeComponent()
'Add initialization code after the call to InitializeComponent
End Sub
Private Function GetSql(ByVal Name As String) As String
Try
' Gets the current assembly.
Dim Asm As [Assembly] = [Assembly].GetExecutingAssembly() ' Resources are named using a fully qualified name.
Dim strm As Stream = Asm.GetManifestResourceStream( _ Asm.GetName().Name + "." + Name) ' Reads the contents of the embedded file.
Dim reader As StreamReader = New StreamReader(strm) Return reader.ReadToEnd()
Catch ex As Exception MsgBox("In GetSQL: " & ex.Message)
Throw ex End Try
End Function
Private Sub ExecuteSql(ByVal DatabaseName As String, ByVal Sql As String) Dim Command As New SqlClient.SqlCommand(Sql, masterConnection) ' Initialize the connection, open it, and set it to the "master" database
masterConnection.ConnectionString = DBCustomAction.My.Settings.masterConnectionString
Command.Connection.Open()
Command.Connection.ChangeDatabase(DatabaseName)
Try
Command.ExecuteNonQuery()
Finally
' Closing the connection should be done in a Finally block
Command.Connection.Close()
End Try
End Sub
Protected Sub AddDBTable(ByVal strDBName As String) Try
' Drop Database if exists.
ExecuteSql("master", "ALTER DATABASE TrainTrack SET SINGLE_USER WITH ROLLBACK IMMEDIATE") ExecuteSql("master", "Drop database TrainTrack")
Catch ex As Exception ' Reports any errors and abort.
End Try
Try
' Creates the database.
ExecuteSql("master", "CREATE DATABASE " + strDBName) ' Creates the tables.
ExecuteSql(strDBName, GetSql("sql.txt")) Catch ex As Exception ' Reports any errors and abort.
MsgBox("In exception handler: " & ex.Message) Throw ex End Try
End Sub
Public Overrides Sub Install(ByVal stateSaver As _ System.Collections.IDictionary)
MyBase.Install(stateSaver) 'AddDBTable(Me.Context.Parameters.Item("dbname"))
AddDBTable("TrainTrack") 
 End Sub 
 End Class


  1. On the Build menu, choose Build DBCustomAction.

To create a deployment project

  1. On the File menu, click Add, and then click New Project.
  2. In the Add New Project dialog box, open the Other Project Types node and select Setup and Deployment Projects in the Project Type pane. Then select Setup Project in the Templates pane. In the Name box, type DBCustomAction_Setup.
  3. In the Properties window, select the ProductName property and type DB Installer.
  4. In the File System Editor, select the Application Folder. On the Action menu, click Add, and then click Project Output.
  5. In the Add Project Output Group dialog box, select Primary output for the DBCustomAction project.

To create a custom installation dialog

  1. Select the DBCustomAction_Setup project in Solution Explorer. On the View menu, point to Editor, and choose User Interface.
  2. In the User Interface Editor, select the Start node under Install. On the Action menu, choose Add Dialog.
  3. In the Add Dialog dialog box, select the Textboxes (A) dialog, then click OK.
  4. On the Action menu, choose Move Up. Repeat until the Textboxes (A) dialog is above the Installation Folder node.
  5. In the Properties window, select the BannerText property and type Specify Database Name.
  6. Select the BodyText property and type This dialog allows you to specify the name of the database to be created on the database server.
  7. Select the Edit1Label property and type Name of database:.
  8. Select the Edit1Property property and type CUSTOMTEXTA1.
  9. Select the Edit2Visible, Edit3Visible, and Edit4Visible properties and set them to False.

To create a custom action

  1. Select the DBCustomAction_Setup project in Solution Explorer. On the View menu, point to Editor, and then click Custom Actions.
  2. In the Custom Actions Editor, select the Install node. On the Action menu, choose Add Custom Action.
  3. In the Select item in project dialog box, double-click the Application Folder.
  4. Select Primary output from DBCustomAction (Active), then click OK to close the dialog box.
  5. Make sure that Primary output from DBCustomAction (Active) item is selected in the Custom Actions Editor. In the Properties window, select the CustomActionData property and type /dbname=[CUSTOMTEXTA1].
  6. On the Build menu, choose Build DBCustomAction_Setup.

To install on your development computer

Select the DBCustomAction_Setup project in Solution Explorer. On the Project menu, choose Install.

Wednesday, 22 February 2012

Entity Framework 4.0 - Learn to Create Databases from the Model

The ADO.NET Entity Framework (EF) is object relational mapping software for ADO.NET, used to develop applications that interact with data. It provides a mapping between the relational database schemas and objects. This technology is helpful for architecting, designing and developing at a conceptual level without worrying about details. ADO.NET Entity Framework allows developers to program against the Entity Relationship (Object) model, as opposed to querying against the relational database, mainly concentrating on the data. The main benefit is to make data oriented applications maintenance friendly.

EF - Benefits

  • The application won’t be tied to hard-coded dependencies on the storage schema or database.
  • The conceptual model and the storage-specific schema mappings can change without changing the application code.
  • Developers can work more easily with an object model that can be mapped to various storage schemas, and can be implemented in different databases.
  • The ability to map multiple conceptual models to a single storage schema.
Model First Development was introduced in VS 2010, along with .NET Framework 4.0, and the essential idea behind the Entity Framework is to query the model, rather than the database. In this article I will walk through how to generate databases from the model.

Understanding the model

EF maps to the database tables using a model. This model is responsible for mapping the application’s entities and their relationships to the data held in the physical database. It’s a combination of three layers, and is stored as an Entity Data Model (.edmx) file. .edmxis an XML based file that consists of these 3 layers.
  1. Storage Layer: this is defined with Store Schema Definition Language (SSDL). Table structures and their relationships are defined here.
  2. Conceptual Layer: this is defined with Conceptual Schema Definition Language (CSDL). Business entities and their relationships are described in the conceptual schema.
  3. Mapping Layer. This is defined with Mapping Specification Language (MSL). It maps the conceptual schema to the storage schema. The mapping schema describes how the business entities map to the database schema, and how database tables map to the entities in the model.
If you right click on an .edmx file and open it with XML Text Editor, you can view the EDMX schema layers.
At runtime, the .edmx is split into three different files: .ssdl, .csdl and .msl.
To construct any database, we need define the tables for the data storage. Here, tables are mapped to entities, hence the need to have entities and their relationships defined in the model. The model can be created using an .edmx file in Entity Framework and each entity in a specific Entity Framework is mapped as a table inside the database, and each property in an entity is mapped to a corresponding column in the specified table.

Creating the model

Let us start by creating a Class Library Application in Visual Studio 2010, so that we can re-use the models. We select the Add ->new Item , then the Data tab in the Visual Studio 2010 Installed Templates list, and finally select ADO.NET Entity Data Model. We’ll name our .edmx ‘Company’, and click the Add button, in the lower right corner, as shown below.
Adding a new item
Figure 1: Adding a new item to the class library project.
Adding Company.edmx to the project
Figure 2: Adding Company.edmx to the project.
The moment we click the Add button, the Entity Data Model Wizard appears. This gives us two options to select from:
  1. Generate from database
  2. Empty model
Adding an empty model
Figure 3: Adding an empty model.
We aren’t going to worry about the first option as we are interested in creating a database from the model only. We’ll select the second option, Empty model, and click the Finish button. As you can see from the screenshot above, this option creates an empty model as a starting point for visually designing a conceptual model from the toolbox. When the project is compiled, classes will be generated from the model. We’ll specify a database connection to map the conceptual model to the storage model later.
If you observe the Solution Explorer, it creates a new reference related to Entity Framework, System.Data.Entity, responsible for working with the Entity Framework related APIs. This reference is added only after adding an .edmx file.
The System Data Entity
Figure 4: The System.Data.Entity reference, added after an .edmx file is created.

Creating entities in the .edmx

Now we need to define the model in this .edmx file by creating entities, which can be done by dragging items from the EF toolbox or from the model itself.
Entity Framework Toolbar
Figure 5: Entity Framework toolbar for creating entities and relationships between entities.
In a Company, we’ll have Employees, Departments and Managers as entities. Let’s create the Employee entity.
We right click on the .edmx file and Click Add → Entity as shown below.
Adding a new entity
Figure 6: Adding a new entity to the Model.
A dialogue box for adding an Entity appears, as shown below.
Entity dialog box
Figure 7: Creating the Employee entity.
We’ll name the entity ‘Employee’. The Entity Set is automatically pluralized by the IDE, based on the Entity Name.
It also creates a Key property - ID - of type Integer. This Key is called the Entity Key in the model, and mapped as the Primary Key in the database. If you do not want to create the Entity Key property for a particular entity you can uncheck this property. Next, we’ll press OK.
Now we have created an entity, we can start adding some more properties for it. There are two ways of doing this:
  1. Right click on the entity to add new properties such as EmpName, Description, DOB and Address.
    Creating scalar properties
    Figure 8: Creating scalar properties for the entities.
  2. 2. Select the Id property and hit enter to add some more scalar properties (scalar properties map to a single field in the storage layer).

Editing entity properties

To edit the attributes for entity properties, you select the property and right click it, then navigate to properties. The properties that you set are reflected in the database that is going to be created from the model.
Selecting the Employee entity’s properties
Figure 9: Selecting the Employee entity’s properties.
Editing the Employee entity’s properties
Figure 10: Editing the Employee entity’s properties.
Note that here the identity property for the primary key column is set automatically by the IDE. The Nullable attribute allows or disallows any null values inside the column.

Creating more entities for the model

Now let us create a department entity with the properties Id, DeptName, DeptDescription, and DeptCode, as shown to the left.
Fig11: The Department entity.
The manager entity

Let us also create a Manager entity with ManagerId, EmployeeID as properties. The key for this entity is the combination of ManagerId and EmployeeID. One employee can report to multiple managers.
Figure 12: The Manager entity.


Applying relationships to the entities

An employee cannot be member of multiple departments. A department, however, should accommodate multiple employees, so the relationship between employee and department is one to many. Let us add a new association between these two tables. For this, we right click on the model, and click Add → Association…
Adding an association relationship
Figure 13: Adding an Association relationship to the table.
This opens the following window, with the option to add relationships between these two tables.
Adding an association between emplyee and department
Figure 14: Adding an association between Employee and Department.
We need to make provision for the department entity to have many instances of the Employee entity, so we map the relationship between the department and the Employee entities as one to many, as shown above. Clicking the check box “Add foreign key properties to the ‘Employee’ entity” helps to create the foreign key relationships between these two tables automatically.
If we observe the Employee entity, we notice that departmentid is being added to the employees table for the foreign key relationship in the database.
A manager can have more than one employee reporting to him, and an employee can report to multiple managers, so the relationship between the Employee entity and the manager entity is many to many. We need to add a many to many association between these two entities. Because a manager is also an employee of the company, the manager class gets inherited from the Employee class. To add this inheritance relationship, right click on the model and select Add →Inheritance…
Adding an inheritance
Figure 15: Adding an inheritance relationship for entities.
In the dialog box, select Employee as the base entity as and Manager as the derived entity.
Defining the inheritance
Figure 16: Adding inheritance between the Employee and Manager entities.
The final model
Figure 17: The final model after applying all the relationships.
We’ve now finished adding relationships between our entities, and are ready to generate our database.

Changing DatabaseSchema Name

Entity Framework Model uses dbo as the default schema name. In order to change that, right click on the .edmx in the VS2010 IDE, and click on Properties. The ConceptualEntityModel properties window appears as shown below. Make sure that you change the name according to the project, so that the script files are generated accordingly.
Conceptual Model Properties
Figure 18: Conceptual Model Properties.
If we look at Company.edmx in the automatic editor selector, we can view the XML schema code that’s been generated from the design. SSDL, CSDL, and MSL are created by the IDE, based on the entities and their relationships. Each time we make changes to the model, this schema gets recreated. To view this, we need to right click on the .edmx file and open with the XML (Text) Editor.
Opening the .edmx with the XML editor
Figure 19: Opening the .edmx with the XML editor.
Here we can examine how the Entities and their relations are mapped in the conceptual model, and how the storage schema and conceptual schema are actually mapped in the mapping layer.
We can also examine the Company.designer.cs file, a partial class inherited from ObjectContext.
All the entities that are created from the IDE inherit from Entityobject. Their code is generated automatically with properties and datacontract attributes. Whenever we modify and save the .edmx file, the classes or the automatic code are regenerated by the IDE.

Generating the database from the model

Now we need to right click and select Generate Database from the Model, from the context menu.
Generate Database from the Model
Figure 20: Generate Database from the Model
We need to have an empty or existing database created in SQL Server to generate a database from the model. I have created an empty database, called Company, in SQL Server 2008. If you do not have existing connections, then click on new Connection button and specify your credentials, as shown below.
Connection string credentials
Figure 21: Connection string credentials.
Now, choose the appropriate data connection from the dropdown list, as shown below. Here we also have the option to save the connection string in app.config, which contains connection string metadata and various settings for the project. The syntax is somewhat different from the normal connection string.
Choosing the data connection for the creation of a database from our model
Figure 22: Choosing the data connection for the creation of a database from our model.
Pressing Next generates a file called Company.edmx.sql. Note that the constraints, foreign key relationships, and primary keys in the tables are created based on the properties specified in the model.
The generated Company.edmx.sql file
Figure 23: The generated Company.edmx.sql file
Finally, click on the Finish button. The IDE creates this .sql script file for us:

-- ----------------------------------------------------------------------------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 04/25/2011 17:30:49
-- Generated from EDMX file: D:\Training\AJAX\ModelDatabase\ModelDatabase\Company.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Company];
GO
IF SCHEMA_ID(N'Hima') IS NULL EXECUTE(N'CREATE SCHEMA [Hima]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------


-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Employees'
CREATE TABLE [Hima].[Employees] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [EmpName] nchar(4000)  NOT NULL,
    [EmpDescription] nvarchar(max)  NOT NULL,
    [DOB] datetime  NOT NULL,
    [Address] nvarchar(max)  NOT NULL,
    [DepartmentId] int  NOT NULL
);
GO

-- Creating table 'Departments'
CREATE TABLE [Hima].[Departments] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DeptName] nvarchar(max)  NOT NULL,
    [DeptDescription] nvarchar(max)  NOT NULL,
    [DeptCode] nchar(4000)  NOT NULL
);
GO

-- Creating table 'Employees_Manager'
CREATE TABLE [Hima].[Employees_Manager] (
    [ManagerId] int  NOT NULL,
    [EmployeeID] int  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'EmployeeManager'
CREATE TABLE [Hima].[EmployeeManager] (
    [Employees_Id] int  NOT NULL,
    [Managers_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Employees'
ALTER TABLE [Hima].[Employees]
ADD CONSTRAINT [PK_Employees]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Departments'
ALTER TABLE [Hima].[Departments]
ADD CONSTRAINT [PK_Departments]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Employees_Manager'
ALTER TABLE [Hima].[Employees_Manager]
ADD CONSTRAINT [PK_Employees_Manager]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Employees_Id], [Managers_Id] in table 'EmployeeManager'
ALTER TABLE [Hima].[EmployeeManager]
ADD CONSTRAINT [PK_EmployeeManager]
    PRIMARY KEY NONCLUSTERED ([Employees_Id], [Managers_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Employees_Id] in table 'EmployeeManager'
ALTER TABLE [Hima].[EmployeeManager]
ADD CONSTRAINT [FK_EmployeeManager_Employee]
    FOREIGN KEY ([Employees_Id])
    REFERENCES [Hima].[Employees]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Managers_Id] in table 'EmployeeManager'
ALTER TABLE [Hima].[EmployeeManager]
ADD CONSTRAINT [FK_EmployeeManager_Manager]
    FOREIGN KEY ([Managers_Id])
    REFERENCES [Hima].[Employees_Manager]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EmployeeManager_Manager'
CREATE INDEX [IX_FK_EmployeeManager_Manager]
ON [Hima].[EmployeeManager]
    ([Managers_Id]);
GO

-- Creating foreign key on [DepartmentId] in table 'Employees'
ALTER TABLE [Hima].[Employees]
ADD CONSTRAINT [FK_DepartmentEmployee]
    FOREIGN KEY ([DepartmentId])
    REFERENCES [Hima].[Departments]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DepartmentEmployee'
CREATE INDEX [IX_FK_DepartmentEmployee]
ON [Hima].[Employees]
    ([DepartmentId]);
GO

-- Creating foreign key on [Id] in table 'Employees_Manager'
ALTER TABLE [Hima].[Employees_Manager]
ADD CONSTRAINT [FK_Manager_inherits_Employee]
    FOREIGN KEY ([Id])
    REFERENCES [Hima].[Employees]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- ---------------------------------------------------------------------------------------------------------------------


This script can be given to the DBA to run, creating the database. Or, we can right click on the script file and press Execute SQL or Control + Shift +E, to run a script against SQL Server 2008 database from the IDE.
The SQL script is generated from the SSDL contained in the .edmx file. This script contains lots of DDL statements to create the database tables, which correspond to the tables described in the SSDL. Entities are mapped as tables in the database and scalar properties are mapped as columns in the corresponding tables.

Summary

In this article we have learnt how to create a database from the model in EF 4.0, an approach also called ‘Model First‘. We’ve looked at the structure of an .edmx file, and its significance, and learnt how to create entities, properties for the entities, and relationships between the entities. As we’ve seen, Model First Development helps to create a model for the entities, then has Visual Studio 2010 generate the DDL to create a database with matching tables, columns and relationships for the entities.

Monday, 2 January 2012

How to make Set up in .net

Step 1
Create your own windows application. Create a new Windows application project in C# and named it as Sample.
d01
Step 2
Design your own application. Here we have a simple login form for example.
d02
Step 3
After completing the design and coding, build the solution of the project in release mode.
d03
Step 4
Check the Release folder for the file “ProjectName.exe”. Here in this example we have the project name as sample so we can find a file with the name Sample.exe. Double click the executable file and check the example.
d04
Step 5
Create a Deployment Project. Select the “Other Project Types” -> “Setup and Deployment” -> “Setup project”. Here we have the setup project for example as “SampleSetup”.
d05
Step 6
Add the Sample.exe project application file inside the “Application Folder”.
d06
Step 7
To make a shortcut for the project right click “File System on Target Machine” and create shortcut of the application. Here in this example the project shortcut is created in program files folder.
d07
Step 8
Create the shortcut of the application.
d08
Step 9
Rename the shortcut of the application.
d09
Step 10
Move the Shortcut file to specified target. Note if you need another shortcut for some other target also create use same steps.
d10
Step 11
Now build the solution in release mode.
d11
Step 12
The setup file created in release folder of the project specified path.
d12
Step 13
Run the setup, step the path to extract.
d13

d14
d15
Step 14
The SampleSetup project is extracted and shortcuts are created. Now run your application.
d16