2012-11-03 71 views
-5

我有一個數據庫表名爲nama總ROW Mysql的C#

id | tomi | asep | andre | 
-------------------------- 
1 | 123 | 321 | 545 | 

當我使用下面的SQL查詢:

select * from nama; 

我得到這樣的輸出:

1 123 321 545 

這總共4列。

我怎樣才能得到總列在C#與MySQL?

+0

它只有1排四列 –

+1

目前還不清楚你問什麼。你想知道如何: 返回行數? 返回列數? 返回SUM /(總)值一列或多列? – Richthofen

+0

sory編輯,那共4欄。 如何獲得在C#中合計列與MySQL – TomiSintara

回答

2

一個簡單的例子可以是:

MySqlCommand command = new MySqlCommand(); 
command.CommandText = "select * from nama;"; 

MySqlDataReader reader = command.ExecuteReader(); 
DataTable tblNama = new DataTable(); 
tblNama.Load(reader); 

int numR = tblNama.Rows.Count; //Number of Rows ... 
int numC = tblNama.Columns.Count; //Number of Columns ... 
+0

TQ其workkkkk – TomiSintara

+0

很高興知道,反正你應該在這裏閱讀規則在計算器上... :-) – aleroot