-2

I'm using TableAdapterManager, TableAdapter, BindingSource and DataSet for my record editor form. I would like to automate as many checks as possible. For example I want to know if field X has the "not null" option or not. If so, I can run the associated input filter at application level for the corresponding TextBox's Text property. (For example trimming white-spaces, checking after for equality with empty string, ...)

  • Visual Studio 2010
  • Microsoft SQL Server 2005
Notinlist
  • 16,144
  • 10
  • 57
  • 99
  • I think a look at this question will pay off: http://stackoverflow.com/questions/887370/sql-server-extract-table-meta-data-description-fields-and-their-data-types – mklein Nov 08 '11 at 13:52
  • That solution is tightly bound to SQL server kind. May or may not work with another. These properties should appear at application level somehow, I think. – Notinlist Nov 08 '11 at 14:04
  • More precisely: Why do I have the ADODB _layer_? I should not be doomed to raw SQL commands if I want to know if a field has the `not null` option or not. – Notinlist Nov 08 '11 at 14:16

1 Answers1

0
DataRow dr = ((DataRowView)table1BindingSource.Current).Row;
int maxlen = dr.Table.Columns["field1"].MaxLength;
bool allownull = dr.Table.Columns["field1"].AllowDBNull;
// ...
Notinlist
  • 16,144
  • 10
  • 57
  • 99