473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Add numbers which are present in db

66
how to add numbers which is present in database on date basis in vb6.0 using adodc
Oct 5 '07 #1
15 1418
QVeen72
1,445 Expert 1GB
Hi,

use SQL Query:

Select Sum(Qty) From MyTable

Regards
Veena
Oct 5 '07 #2
jrtox
89
how to add numbers which is present in database on date basis in vb6.0 using adodc
Did you mean Sum of Numbers, which Belong to that particular date.
eg, Sum of numbers for the date of July 05, 2007
and another sum for the date july 06, 2007 so on and so fort?
Oct 5 '07 #3
rekhasc
66
Did you mean Sum of Numbers, which Belong to that particular date.
eg, Sum of numbers for the date of July 05, 2007
and another sum for the date july 06, 2007 so on and so fort?
i want to add numbers(amounts) of seven days,month and so on.......date should automatically updated....... i want code for both..........
Oct 6 '07 #4
QVeen72
1,445 Expert 1GB
Hi,

Use this Query :

Expand|Select|Wrap|Line Numbers
  1. sSQL = "Select Sum(Amt) From MyTable Where MyDate Is Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# " 
  2.  
REgards
Veena
Oct 6 '07 #5
rekhasc
66
Hi,

Use this Query :

Expand|Select|Wrap|Line Numbers
  1. sSQL = "Select Sum(Amt) From MyTable Where MyDate Is Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# " 
  2.  
REgards
Veena


Private Sub cmdshow_Click()
sSQL = "Select Sum(Amount) From xdetails Where MyDate Is Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# "
txtTotal.Text = Val(sSQL)
End Sub

but its not adding the amount,........
mydatabase contains two fields, one is date and another one is amount, when i enter 2 dates it should show the sum of amounts which is in database b/w these dates. ( in database i have given the date format as medium date)
Oct 6 '07 #6
QVeen72
1,445 Expert 1GB
hI,

What is backend db ..?

REgards
Veena
Oct 6 '07 #7
rekhasc
66
hI,

What is backend db ..?

REgards
Veena

i am using ms access 2000
instead of entering date in text box can i use combobox
Oct 6 '07 #8
QVeen72
1,445 Expert 1GB
Hi,

thers is no IS in the query :

sSQL = "Select Sum(Amt) From MyTable Where MyDate Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "#


Yes, u can use ComboBox :
CDate(Combo1.Text)

Regards
Veena
Oct 6 '07 #9
rekhasc
66
Hi,

thers is no IS in the query :

sSQL = "Select Sum(Amt) From MyTable Where MyDate Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "#


Yes, u can use ComboBox :
CDate(Combo1.Text)

Regards
Veena




Dim sSQL As String


Private Sub cmdTotal_Click()
sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# "
txtTotal.Text = Val(sSQL)
End Sub


its not adding the amount..........
when i click the total cmd its coming 0
Oct 6 '07 #10
QVeen72
1,445 Expert 1GB
Hi,

you have to open a recordset, just by giving Val() will not work..
what i have given is just a Query.
To open a record set, just go through this thread

Regards
Veena
Oct 6 '07 #11
rekhasc
66
Hi,

you have to open a recordset, just by giving Val() will not work..
what i have given is just a Query.
To open a record set, just go through this thread

Regards
Veena


Dim sSQL As String

Private Sub cmdAdd_Click()
Adodc1.Recordset.AddNew
Text1.SetFocus
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdTotal_Click()
sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# "
txtTotal.Text = Val(sSQL)
End Sub
Oct 6 '07 #12
QVeen72
1,445 Expert 1GB
Hi,

Declare a Connection object, Recordset Object :

Expand|Select|Wrap|Line Numbers
  1. Dim sSQL As String 
  2. Dim AConn As New ADODB.Connection
  3. Dim RST As New ADODB.Recordset
  4. With AConn
  5.   .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.mdb"
  6.   .Open
  7. End With
  8. sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# "
  9. RST.Open sSQL, AConn
  10. If Not RST.EOF Then
  11.   txtTotal.Text = RST(0) & ""
  12. End If
  13. RST.Close
  14.  
Replace C:\MyDb.mdb, to ur actual database path

REgards
Veena
Oct 6 '07 #13
rekhasc
66
Hi,

Declare a Connection object, Recordset Object :

Expand|Select|Wrap|Line Numbers
  1. Dim sSQL As String 
  2. Dim AConn As New ADODB.Connection
  3. Dim RST As New ADODB.Recordset
  4. With AConn
  5.   .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.mdb"
  6.   .Open
  7. End With
  8. sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# "
  9. RST.Open sSQL, AConn
  10. If Not RST.EOF Then
  11.   txtTotal.Text = RST(0) & ""
  12. End If
  13. RST.Close
  14.  
Replace C:\MyDb.mdb, to ur actual database path

REgards
Veena


thank you.....
thanks a lot..........
it helps me a lot........ i am d beginner of vb...... i want to learn more about vb..... thats y i m doing small pgms......... thank u for your cooperation
Oct 6 '07 #14
rekhasc
66
hi.........

i want to know about how to generate a graphs on this query basis.....(daily,weekly,monthly,yearly,totally)... ........ and also how to print these result plz help me.................
Oct 7 '07 #15
Ali Rizwan
925 512MB
Hi,

Declare a Connection object, Recordset Object :

Expand|Select|Wrap|Line Numbers
  1. Dim sSQL As String 
  2. Dim AConn As New ADODB.Connection
  3. Dim RST As New ADODB.Recordset
  4. With AConn
  5.   .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.mdb"
  6.   .Open
  7. End With
  8. sSQL = "Select Sum(Amount) From Table1 Where date Between #" & txtFromDate.Text & "# And #" & txtToDate.Text & "# "
  9. RST.Open sSQL, AConn
  10. If Not RST.EOF Then
  11.   txtTotal.Text = RST(0) & ""
  12. End If
  13. RST.Close
  14.  
Replace C:\MyDb.mdb, to ur actual database path

REgards
Veena
Hello Veena
How can i do this with ADODC1.
I have three ADODCs on a form and i want to do this (sum of a column,field) with one of them with no date, time anyother restrictions iy just calculates the monthly expenses.
Thanx
Oct 12 '07 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: August1 | last post by:
A handful of articles have been posted requesting information on how to use these functions in addition to the time() function as the seed to generate unique groups (sets) of numbers - each group...
23
by: MConly | last post by:
Can you tell me what happens inside CPU when I rand() ? Where can I find the true rand function implemented ? I have heard that rand() in C/C++ is n't a good one but why it isn't a good one, are...
19
by: Eduardo Bezerra | last post by:
Hi, I'm looking for an efficient way to create the oposite of a list of numbers. For example, suppose I have this list of numbers: 100 200 300
2
by: rammohan | last post by:
i want to implement an option similar to line numbers option in c# editor. how can i display line numbers on left side in text box.how can i know the present cursor location with respect to...
1
by: peter_k | last post by:
Hi, I've to implement fast library for big numbers arithmetics. I'll store the number in the table of unsigned long variables. And now i've a question: what will be faster: a) storing in one...
25
by: Subra | last post by:
Hi, What is the best way to find the 1000 largest numbers from the file having hell lot of entries ? Can you please help me to find out the way ? Do I need to go for B+ trees ?? Please help,...
2
by: shihaoran | last post by:
I really need help with one my program; it is about arraylist; I do not get it. Can someone please help me with it? Here's the instruction: 1. Your instructor will provide you with a text...
9
by: Chelong | last post by:
Hi All I am using the srand function generate random numbers.Here is the problem. for example: #include<iostream> #include <time.h> int main() {
33
by: Andreas Prilop | last post by:
To get bold numbers in ordered lists, one can write ol { font-weight: bold } ol span { font-weight: normal } <ol> <li><span>......</span></li> <li><span>......</span></li> </ol>
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.