数据表列大小 [英] datatable column size
问题描述
数据表dtTableFields有两列.
身份证和姓名
数据库中的表的名称长度为5
我在这条线上出现错误:
newRow ["Name"] =<-选择一个值->";
当然会抱怨它的大小.
如何在不更改数据库表中字段宽度的情况下修改下面的代码?
谢谢
Hi, the datatable dtTableFields has two column.
ID and name
The table in the database has name of length 5
I get an error on this line:
newRow["Name"] = "<-- Select a value -->";
and ofcourse it complains of the size.
How can I modify the code below without changing the width size of the field in the table in the database please?
Thanks
private void PopulateFieldNames()
{
DataTable dtTableFields = TableFieldsGet(strSomeName);
DataRow newRow = dtTableFields.NewRow();
newRow["Name"] = "<-- Select a value -->";
dtTableFields.Rows.InsertAt(newRow, 0);
cboTableFields.Items.Clear();
cboTableFields.DisplayMember = "Name";
cboTableFields.ValueMember = "ID";
cboTableFields.DataSource = dtTableFields;
cboTableFields.SelectedIndex = 0;
}
推荐答案
检查以下值:
Check the value of the following:
dt.Columns("Name").MaxLength
您可以根据需要进行更改,但是请记住,如果要将数据保存回数据库,则必须确保将列宽截断以适合数据库列.否则,尝试保存时会出现错误.
You can change it if you need to, however remember that if you''re going to save the data back to a database, you''ll have to make sure that the column width is truncated to fit the database column. Otherwise, you''ll get an error when you try to save.
这篇关于数据表列大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!