Problem Statement

You are required to implement web form for product Catalog Update.

Solution:

Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Product Catalog Update</title>
    <style>
        .text-box{
            margin-bottom : 10px;
        }
        label{
            display: inline-block; width:100px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <h2>Product Catalog Update</h2>
        <div class="text-box">
            <label>ID: </label><asp:TextBox ID="textID" runat="server"></asp:TextBox>
        </div>
        <h3>Enter Product's New Details:</h3>
        <div class="text-box">
            <label>New Description: </label><asp:TextBox ID="txtDesc" runat="server"></asp:TextBox>
        </div>
        <div class="text-box">
            <label>New Price: </label><asp:TextBox ID="TextPrice" runat="server"></asp:TextBox>
        </div>
        <br />
        <asp:Button ID="submitbtn" runat="server" Text="Submit" />
        <br /><br />
        <asp:Label ID="status" runat="server" Text=""></asp:Label>
    </form>
</body>
</html>
                
Default.aspx.vb
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page


    Protected Sub submitbtn_Click(sender As Object, e As EventArgs) Handles submitbtn.Click
        Dim conn As SqlConnection
        conn = New SqlConnection

        Dim constr = "workstation id=IAD_Lab_DB.mssql.somee.com;packet size=4096;user id=afzaalahmad_SQLLogin_1;pwd=5kvkluvzd7;data source=IAD_Lab_DB.mssql.somee.com;persist security info=False;initial catalog=IAD_Lab_DB;TrustServerCertificate=True"
        conn.ConnectionString = constr

        Dim cmd As SqlCommand = New SqlCommand
        cmd.Connection = conn

        cmd.CommandText = "Update PRODUCT_T "
        cmd.CommandText &= "set Standard_Price = " & TextPrice.Text
        cmd.CommandText &= " , Product_Description = '" & txtDesc.Text & "' "
        cmd.CommandText &= "WHERE PRODUCT_Id = " & textID.Text

        Dim inserted As Integer = 0
        Try
            conn.Open()
            inserted = cmd.ExecuteNonQuery()
            If inserted = 1 Then
                status.Text = inserted & " records updated"
            Else
                status.Text = "No record updated!"
            End If
        Catch ex As Exception
            status.Text = ex.Message
        Finally
            cmd.Dispose()
            conn.Close()
        End Try

    End Sub
End Class

                

Output:

Customer table before addition
image of display page
Customer table after addition
Web hosting by Somee.com