Hi Frends,
Can I use View Insted of query in my code.
If yes Then plz tell me how can.

Protected Sub checkavailabilityusername(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles usersformview.ItemInserting
        Dim name As TextBox
        Dim username As String
        Dim Query As String
        Dim dr As SqlDataReader
        Dim db As DBConnection
        db = DBConnection.getConnection()
        name = usersformview.FindControl("username")
        username = name.Text

        Query = "SELECT [username] FROM [customer] where [username] = '" & username & "' "
        dr = db.executeQuery(Query)
        If dr.Read = True Then
            e.Cancel = True

            errmsg.Text = "<h5 style='color:#270000;'> The User Name you have entered is already exists.Please enter another  User Name.</h5>"
            'Response.Write("<h4 color=red> The Country name you have entered is already exists.Please enter another the country name.</h4>")

        End If
        dr.Close()

    End Sub

Thanks

A view is, in essence, a virtual table which is based on SQL SELECT query. It does not physically exist. A view is an object that can derive data from one or more tables. For Eg Suppose there is a Users Table named customer which has some 100 columns and your wish to create a view with just the userName column

CREATE VIEW view_UserNames AS
SELECT UserName
FROM customer

Now rather than using the customer table you can use the view 'view_UserNames' in you code.

A view is, in essence, a virtual table which is based on SQL SELECT query. It does not physically exist. A view is an object that can derive data from one or more tables. For Eg Suppose there is a Users Table named customer which has some 100 columns and your wish to create a view with just the userName column

CREATE VIEW view_UserNames AS
SELECT UserName
FROM customer

Now rather than using the customer table you can use the view 'view_UserNames' in you code.

Ok Thanq

This article has been dead for over six months. Start a new discussion instead.