Click here to Skip to main content
11,804,574 members (90,692 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB VB.NET
I have a table w/c is in the data grid view... it has 4 attributes ID,Description,Unit Price and Unit Quanity... now part of the task is whenever New record was added, automatically the Unit Price and The Unit Quantity will be multiplied and a derived attribute w/c is Total Price will appear ... What Code will I use to perform this and where will it will inserted?

Imports System.Data.OleDb
Public Class frmMain
    Dim myconnection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\order\Order\Order\Orders.accdb")
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sql As String
        sql = " Select * from Orders"
        Dim da As New OleDb.OleDbDataAdapter(sql, myconnection)
        Dim dt As New DataTable("tblOrder")
        dgv1.DataSource = dt.DefaultView

    End Sub

    Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
        Dim sqlsearch As String
        sqlsearch = "SELECT * FROM Orders WHERE ID LIKE '%" & txtSearch.Text & "%'" & " OR Description LIKE '%" & txtSearch.Text & "%'"
        Dim da As New OleDbDataAdapter(sqlsearch, myconnection)
        Dim dt As New DataTable("Orders")
        dgv1.DataSource = dt.DefaultView

    End Sub
    Private Sub cboSearch_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboSearch.SelectedIndexChanged
        If Not cboSearch.Text = cboSearch.SelectedText Then
            btnSave.Enabled = True
        End If

        Dim MyVariable As String
        MyVariable = cboSearch.Text
    End Sub
    Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
    End Sub
    Private Sub RefreshDGV()
    End Sub
    Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
    End Sub
End Class
Posted 6-Oct-12 20:40pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 3,205
1 Maciej Los 1,950
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,187

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100