|
-
Jul 26th, 2005, 05:23 AM
#1
Thread Starter
Junior Member
flexgrid and sql
When I run 2 sql queries and return the result to flexgrid , I can only see data from the 2ns query and not the first,plz help
VB Code:
sql = "select count(*) as orders, date as jdate from data where date between ' " & Format(Form1.dtp1.Value, "mm-dd-yyyy") & " ' and ' " & Format(Form1.dtp2.Value, "mm-dd-yyyy") & " ' detail = 'order' group by date"
rs1.Open sql, gcn, adOpenStatic, adLockOptimistic
If rs1.RecordCount <> 0 Then
rs1.MoveFirst
Do While Not rs1.EOF
sql1 = "insert into tmp(col1,col2) values (" & rs1("jdate") & "," & rs1("orders") & ")"
rs2.Open sql1, con, adOpenDynamic, adLockOptimistic
rs1.MoveNext
Loop
End If
sql2 = "select count(*) as torders, date as jdate from data where date between ' " & Format(Form1.dtp1.Value, "mm-dd-yyyy") & " ' and ' " & Format(Form1.dtp2.Value, "mm-dd-yyyy") & " ' group by calldate"
rs3.Open sql2, gcn, adOpenStatic, adLockBatchOptimistic
If rs3.RecordCount <> 0 Then
rs3.MoveFirst
Do While Not rs3.EOF
sql3 = "insert into tmp(col3) values (" & rs3("torders") & ")"
rs4.Open sql3, con, adOpenDynamic, adLockOptimistic
rs3.MoveNext
Loop
End If
rs2.Open "select * from tmp", con, adOpenStatic, adLockOptimistic
Set MSHFlexGrid1.DataSource = rs2
Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
Last edited by Hack; Jul 26th, 2005 at 05:56 AM.
-
Jul 26th, 2005, 08:11 AM
#2
Frenzied Member
Re: flexgrid and sql
I think you are overlaying the results of the first recordset with the results of the second recordset.
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
-
Jul 26th, 2005, 08:30 AM
#3
Re: flexgrid and sql
Your second loop should be UPDATEing the apropriate record in the temp table instead of INSERTing a new record.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|