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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.