如何在Asp.Net中的Gridview表中显示Mysql数据库列作为行 [英] How Do I Display Mysql Database Columns As Rows In A Gridview Table In Asp.Net
本文介绍了如何在Asp.Net中的Gridview表中显示Mysql数据库列作为行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个mysql数据库表,我希望将表的列显示为datagrid表中列下的行,并将其值显示在同一个表中的另一列下。请问我该怎么做。
i能够使用下面的代码将mysql表绑定到datagrid
i have a mysql database table for which i want to display the columns of the table as rows under a column in a datagrid table and its values under another column in the same table. please how to i go about it.
i have been able to bind the mysql table to the datagrid using the code below
MySqlConnection conn = new MySqlConnection(connection);
MySqlCommand cmd = new MySqlCommand("select IdCardFee, RegFee, ICT, Cult, PolyInfoBook, Caution, StuHandbook, ExamFee, Games, Matric, eReg, DevLevy, CertVeri, TertHealth, Tuition, Library, Total from pla20132014.schoolfee where department = @dept", conn);
MySqlDataAdapter ad = new MySqlDataAdapter();
cmd.Parameters.Add("@dept", MySqlDbType.VarChar).Value = dept.Text;
conn.Open();
ad.SelectCommand = cmd;
DataTable dt = new DataTable();
ad.Fill(dt);
excel.DataSource = dt;
excel.DataBind();
任何帮助将不胜感激。谢谢
any assistance would be appreciated. Thanks
推荐答案
我会先从报告中取出SQL。然后使用枢轴旋转数据。
I would take the SQL out of the report first. Then use a pivot to rotate the data.
这篇关于如何在Asp.Net中的Gridview表中显示Mysql数据库列作为行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文