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
myconnection.Open()
sql = " Select * from Orders"
Dim da As New OleDb.OleDbDataAdapter(sql, myconnection)
Dim dt As New DataTable("tblOrder")
da.Fill(dt)
dgv1.DataSource = dt.DefaultView
RefreshDGV()
myconnection.Close()
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")
da.Fill(dt)
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
MsgBox(MyVariable)
End Sub
Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
frmAdd.Show()
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
1 Replies - 162 Views - Last Post: 07 October 2012 - 05:41 AM
#1
multiplying and coding for derived attributes to appear whenever 2 att
Posted 06 October 2012 - 11:39 PM
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?
Replies To: multiplying and coding for derived attributes to appear whenever 2 att
#2
Re: multiplying and coding for derived attributes to appear whenever 2 att
Posted 07 October 2012 - 05:41 AM
Perform the calculation in your SELECT statement and it will appear in your datagridview.
And example would be
SELECT Description, Price, Quantity, Price * Quantity as Total FROM Orders
This would return 4 columns that last column being Total containing the result of Price * Quantity.
And example would be
SELECT Description, Price, Quantity, Price * Quantity as Total FROM Orders
This would return 4 columns that last column being Total containing the result of Price * Quantity.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|