Link to home
Start Free TrialLog in
Avatar of chrisbarr35
chrisbarr35

asked on

SQL Rownumber command

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

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

>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

Avatar of chrisbarr35
chrisbarr35

ASKER

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.
>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... ? ...
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?
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.
a simple data grid bound to the query should do the job in your visual studio (web) page ...
ASKER CERTIFIED SOLUTION
Avatar of Aftab_Khateeb
Aftab_Khateeb
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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