如何在SQL Server中加载XML列到DataGridView C#
我有一个名为xmlContent的列XML类型的表。 当我将此表加载到DataGridView时,我会看到所有没有XMLContent的列(dataGridView中的列为空)。我该如何解决这个问题?
这是我的C#代码:
using (SqlConnection sqlconnection = new SqlConnection(GetConnectionString()))
{
sqlconnection.Open();
string query = "Select * from RAP_HISTO_FIC_MAT order by FicName ASC";
using (SqlCommand cmd = new SqlCommand(query, sqlconnection))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
SqlParameter xmlColum = new SqlParameter();
DataTable records = new DataTable();
sda.Fill(records);
dataGridView1.DataSource = records;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
}
}
sqlconnection.Close();
}
I have a table with a Column XML type named XMLContent.
When I load this table into DataGridView I see all columns without XMLContent (the column is empty in the DataGridView). How can I do to fix this?
This is my C# code:
using (SqlConnection sqlconnection = new SqlConnection(GetConnectionString()))
{
sqlconnection.Open();
string query = "Select * from RAP_HISTO_FIC_MAT order by FicName ASC";
using (SqlCommand cmd = new SqlCommand(query, sqlconnection))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
SqlParameter xmlColum = new SqlParameter();
DataTable records = new DataTable();
sda.Fill(records);
dataGridView1.DataSource = records;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
}
}
sqlconnection.Close();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论