Click here to Skip to main content
16,004,653 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: duplicate a toolstip Pin
valkyriexp4-Sep-09 7:06
valkyriexp4-Sep-09 7:06 
GeneralRe: duplicate a toolstip Pin
Dave Kreskowiak4-Sep-09 10:02
mveDave Kreskowiak4-Sep-09 10:02 
QuestionUsing VB.Net 2008 with Access 2007 database on Windows Server 2008 Pin
abiemann3-Sep-09 9:25
abiemann3-Sep-09 9:25 
AnswerRe: Using VB.Net 2008 with Access 2007 database on Windows Server 2008 Pin
abiemann3-Sep-09 13:21
abiemann3-Sep-09 13:21 
GeneralRe: Using VB.Net 2008 with Access 2007 database on Windows Server 2008 Pin
εїзεїзεїз3-Sep-09 13:38
εїзεїзεїз3-Sep-09 13:38 
GeneralRe: Using VB.Net 2008 with Access 2007 database on Windows Server 2008 Pin
Dave Kreskowiak3-Sep-09 13:42
mveDave Kreskowiak3-Sep-09 13:42 
QuestionUnsure of phrasing, Subproperty? Pin
EliottA3-Sep-09 5:32
EliottA3-Sep-09 5:32 
AnswerRe: Unsure of phrasing, Subproperty? Pin
Henry Minute3-Sep-09 5:57
Henry Minute3-Sep-09 5:57 
AnswerRe: Unsure of phrasing, Subproperty? Pin
N a v a n e e t h3-Sep-09 5:57
N a v a n e e t h3-Sep-09 5:57 
GeneralRe: Unsure of phrasing, Subproperty? Pin
EliottA3-Sep-09 6:00
EliottA3-Sep-09 6:00 
GeneralRe: Unsure of phrasing, Subproperty? Pin
N a v a n e e t h3-Sep-09 6:09
N a v a n e e t h3-Sep-09 6:09 
GeneralRe: Unsure of phrasing, Subproperty? Pin
EliottA3-Sep-09 6:12
EliottA3-Sep-09 6:12 
GeneralRe: Unsure of phrasing, Subproperty? Pin
N a v a n e e t h3-Sep-09 6:37
N a v a n e e t h3-Sep-09 6:37 
GeneralRe: Unsure of phrasing, Subproperty? Pin
Luc Pattyn3-Sep-09 6:55
sitebuilderLuc Pattyn3-Sep-09 6:55 
GeneralRe: Unsure of phrasing, Subproperty? Pin
EliottA3-Sep-09 7:02
EliottA3-Sep-09 7:02 
QuestionUsing VB.NET 2005 With MySQL Pin
Pasan1483-Sep-09 5:10
Pasan1483-Sep-09 5:10 
AnswerRe: Using VB.NET 2005 With MySQL Pin
EliottA3-Sep-09 5:15
EliottA3-Sep-09 5:15 
AnswerRe: Using VB.NET 2005 With MySQL Pin
εїзεїзεїз3-Sep-09 6:50
εїзεїзεїз3-Sep-09 6:50 
QuestionNeed help with SQL query Pin
sazd13-Sep-09 1:53
sazd13-Sep-09 1:53 
AnswerRe: Need help with SQL query Pin
Johan Hakkesteegt3-Sep-09 2:31
Johan Hakkesteegt3-Sep-09 2:31 
AnswerRe: Need help with SQL query Pin
dan!sh 3-Sep-09 3:34
professional dan!sh 3-Sep-09 3:34 
GeneralRe: Need help with SQL query Pin
sazd13-Sep-09 3:38
sazd13-Sep-09 3:38 
AnswerRe: Need help with SQL query Pin
Pasan1483-Sep-09 5:04
Pasan1483-Sep-09 5:04 
GeneralRe: Need help with SQL query Pin
sazd13-Sep-09 8:39
sazd13-Sep-09 8:39 
I tried something like this to have balance of stock at any date or interval between two dates

Dim cmdText As String = "SELECT pt.ItemId, pt.Description, SUM(pt.Quantity)AS QuantityPurchased, SUM(st.Quantity) AS QuantitySold, (SUM(pt.Quantity) - SUM(st.Quantity)) AS Balance FROM PurchaseTable pt INNER JOIN SalesTable st ON pt.ItemId=st.ItemId WHERE pt.PDate Between @START and @END GROUP BY pt.ItemId, pt.Description"

If con.State = ConnectionState.Closed Then con.Open()
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(cmdText, con)
cmd.CommandType = CommandType.Text

cmd.Parameters.AddWithValue("@START", OleDb.OleDbType.Date).Value = TextBox1.Text
cmd.Parameters.AddWithValue("@END", OleDb.OleDbType.Date).Value = TextBox2.Text

Dim dr As OleDb.OleDbDataReader

If con.State = ConnectionState.Closed Then con.Open()
dr = cmd.ExecuteReader
If Not dr.HasRows Then
MessageBox.Show("No Records Found for Date: " & TextBox1.Text)
Else
MessageBox.Show("Record found for Date: " & TextBox1.Text)
ListView1.Items.Clear()
ListView1.ForeColor = Color.DarkRed
ListView1.GridLines = True

While dr.Read
Dim ls As New ListViewItem(dr.Item("ItemId").ToString())
ls.SubItems.Add(dr.Item("Description").ToString())
ls.SubItems.Add(dr.Item("QuantityPurchased").ToStr ing())
ls.SubItems.Add(dr.Item("QuantitySold").ToString() )
ls.SubItems.Add(dr.Item("Balance").ToString())
ListView1.Items.Add(ls)
End While
End If
But i could not get the desired results. Please advise what i am doing wrong with this.

The problem i am having is as under:
Data in PurchaseTable

PId PDate ItemId Description Price Quantity Amount
1 28/8/2009 1 Coca Cola Normal 1,00 10 10,00
2 28/8/2009 2 Coca Cola Zero 1,00 5 5,00
3 29/8/2009 1 Coca Cola Normal 1,00 5 5,00
4 29/8/2009 2 Coca Cola Zero 1,00 10 10,00

Data in Sales Table is as under:

SId SDate ItemId Description Price Quantity Amount
1 30/8/2009 1 Coca Cola Normal 2,70 2 5,40
2 30/8/2009 2 Coca Cola Zero 2,70 3 7,10
3 31/8/2009 1 Coca Cola Normal 2,70 1 2,70
4 31/8/2009 2 Coca Cola Zero 2,70 2 2,70

The result of query with date range of 28-08-2009 to 29-08-2009 and also with the date range of 28-08-2009 to 31-08-2009 is displayed as under:

Coca Cola Normal 30 6 24
Coca Cola Zero 30 10 20

whereas actually for date range of 28-08-2009 to 29-08-2009 the result should be as under:

Coca Cola Normal 15 0 15
Coca Cola Zero 15 0 15

And with the date range of 28-08-2009 to 31-08-2009 the result should be as under:

Coca Cola Normal 15 3 12
Coca Cola Zero 15 5 10

Pleae advise what i am doing wrong with the query.
Thanks again for your guidance.
QuestionTimer set time click Pin
Bob Beaubien2-Sep-09 21:52
Bob Beaubien2-Sep-09 21:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.