所以,我正在尝试将表的列类型更改为bool,但我不知道这是否可行,因为我使用数据适配器来填充表,如下面的代码所示
private void GetData(string selectCommand)
{
try
{
// Create a new data adapter based on the specified query.
dataAdapter = new OleDbDataAdapter(selectCommand, conn);
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);
// Populate a new data table and bind it to the BindingSource.
System.Data.DataTable table = new System.Data.DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
//table.Columns["Status"].DataType = typeof(bool);
if (table.Rows.Count > 0)
bindingSource1.DataSource = table;
else
{
MessageBox.Show("There is no such Data.", "No Result");
showAll();
}
}
你可以看到评论的行是错误的方式。有人可以帮忙吗?
答案 0 :(得分:0)
分享MSDN Link供您参考。尝试使用GetType()方法更改DataColumn的数据类型。
DataColumn statusColumn = table.Columns["Status"];
statusColumn.DataType = System.Type.GetType("System.Boolean");