Solved

SQL Rownumber command

Posted on 2009-06-28
8
537 Views
Last Modified: 2013-11-27
I have used this command which brings back the results i wish. However im struggling on displaying these results in a textbox. I have figured out using the 'First' command and 'Last' but how do i select the second, third, fourth result in the table.
One textbox would have =First(Fields!statuscode.Value, "DAAS_MSCRM"), but how do i create another textbox that would bring the second result back?
SELECT COUNT(statuscode) AS [statuscode]

FROM FilteredIncident AS CRMAF_FilteredIncident

GROUP BY statuscode;

Open in new window

0
Comment
Question by:chrisbarr35
8 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>However im struggling on displaying these results in a textbox
hmmm. the query can return multiple rows... how do you want to display that in a single text box?

also, should the query not return the statuscode value itself also?
SELECT [statuscode], COUNT(statuscode) AS count_value
FROM FilteredIncident AS CRMAF_FilteredIncident
GROUP BY statuscode;

Open in new window

0
 

Author Comment

by:chrisbarr35
Comment Utility
that may return the statuscode, not really thought of it like that.

But im going to have a CRM report which has six boxes on. And each one will have the result of one of the rows.
So i will have textbox1 to show row 1 result. And textbox2 to show row 2 result and so forth. But i do not know what expression to use to enable this.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>ut im going to have a CRM report which has six boxes on.
I don't know CRM (reports), but I doubt seriously that if you have to put 6 boxes that you are using the correct design technique.
this "report" should be just taking the query results, and display them... ? ...
0
 

Author Comment

by:chrisbarr35
Comment Utility
correct

Im gathering you never use the design tab in Vis Studio.

You can pretty much ignore CRM reports, because i need to get it to work in VS first.

I am probably not using the correct technique, but do you know if it is a possibility?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:chrisbarr35
Comment Utility
the crm report will just make it easily viewable for general users without having to run query. Also not giving them the ability to change anything. So it will just display the results.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
a simple data grid bound to the query should do the job in your visual studio (web) page ...
0
 
LVL 8

Accepted Solution

by:
Aftab_Khateeb earned 500 total points
Comment Utility
Hi,

you could make use of List, Matrix or Table which are small components that are available in the toolbox of your report basically in Visual studio. You could just drag and drop any of these items in your tool and point to the right datasource and dataelement to display.

I think "list" component would be useful in this situation as there is just the list of items you want to display in a report.

Hope this helps

0
 
LVL 1

Expert Comment

by:srinivasraorajulalpudi
Comment Utility
Hi
You can use datagrid, datatable etc for your requirement. below i had attached a code snipped how to do it
the below code works for datagrid, just drag and drop a data grid on to the form and add the below code.
Hope it works.
thanks
srinivas
DataTable dt = new DataTable();          

DataRow dr;

dt.Columns.Add("Item");

dt.Columns.Add("Code");

string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.mdb";

            OleDbConnection myConn = new OleDbConnection();

            myConn.ConnectionString = conn;

            OleDbDataAdapter daScenario = new OleDbDataAdapter("SELECT * FROM data ", myConn);

           

            DataSet dsScen = new DataSet();

            daScenario.Fill(dsScen);

            

	   if (dsScen.Tables[0].Rows.Count != 0)

            {

                for (int i = 0; i < dsScen.Tables[0].Rows.Count; i++)

                {

                    dr["Item"] = dsScen.Tables[0].Rows[i]["name"].ToString());;

        	    dt.Rows.Add(dr);

                }

                

                    

            }

            

            dataGridView1.DataSource = dt;

            dataGridView1.DataMember ="";

Open in new window

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now