In-Memory Data Model
Variable(query) – SqlConnection – SqlDataAdapter – DataTable – WebControl
Insert/Update/Delete Data in Database – Activity Diagram
Sub btnSelect_Click(sender as Object,e as EventArgs)
'Store query into the variable
Dim SQL as String = "select * from products where pid=" & ProdID.text
'Create an Instance of the SqlConnection Class
Dim CON as New SqlConnection ("server=webserve;database=student;uid=student;pwd=icc;")
'Create an Instance of the SqlDataAdapter Class
Dim SDA As New SqlDataAdapter(SQL,Con)
'Create an instance of DataTable to store query results
Dim DT As New DataTable(“Product”)
‘Execute query and fill datatable with results
SDA.Fill(DT)
'Check if the data table has any rows
If DT.Rows.Count > 0 Then
message.text = ""
'Bind data to datagrid/repeater/dropdownlist/listbox
Results.DataSource = DT
Results.DataBind()
Else
'If record was not found, display a message
message.text = " Sorry no records where found in the database"
End If
End Sub
In the HTML page body you create a datagrid/repeater/dropdownlist/listbox using the following ID:
- Results