I have a DataColumn and call the MaxLength Property on it to get the length of data that can go into a field ... but it always returns -1 (yes even on a string field)...
What's going on? - I can get other properties out of it no probs...
Kris
Printable View
I have a DataColumn and call the MaxLength Property on it to get the length of data that can go into a field ... but it always returns -1 (yes even on a string field)...
What's going on? - I can get other properties out of it no probs...
Kris
Did you set the MaxLength Property. MSDN says that
Quote:
The maximum length of the column in characters. If the column has no maximum length, the value is –1 (default).
The MaxLength property is ignored for non-text columns.
the column is a text field in an sql database - and regardless if i set it through code or not i want to get the max length of data that i can enter
Thanks
Kris
If you want the MaxLength property of the DataColumns set when you call Fill on a DataAdapter then you need to set the adapter's MissingSchemaAction property to AddWithKey, rather than the default Add.
If I do that it says things like "column 'Medicare Expiry Date' is read only" - even when I am not attempting to change the column :(
That happens when i go:
vb Code:
Return From xItem As System.Data.DataRowView In BS _ Where xItem.Item("Medicare Expiry Date") <= DateAdd(DateInterval.Day, 7, Date.Today) _ Select xItem
Thanks again
Kris
It just spontaneously says that, or it says that when you do something specific? What exactly would that something be?
If I seem abrupt the please consider the fact that, while this might be the first time today you have failed to provide all the relevant information, it's the tenth time today I've had to ask someone to post information that they really should have thought to post in the first place, and it gets a bit old. If you just post the cause without the effect or the effect without the cause then you haven't provided all the relevant information.
it does it when i call the .count on that enum actually sovb Code:
Dim MedicareExp = From xItem As System.Data.DataRowView In BS _ Where xItem.Item("Medicare Expiry Date") <= Date.Today _ Select xItem msgbox(MedicareExp.count)'ERROR HAPPENS ON THIS LINE
I just tried the following code, with and without the highlighted line, and it worked fine for me.There's obviously something else at play in your case.Code:Using connection As New SqlConnection(builder.ConnectionString)
Using adapter As New SqlDataAdapter("SELECT * FROM PolicyHistory", _
connection)
Dim table As New DataTable
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
adapter.Fill(table)
Me.BindingSource1.DataSource = table
Dim rows = From row In Me.BindingSource1.Cast(Of DataRowView)() _
Where CDate(row("StartDate")) <= Date.Today
MessageBox.Show(rows.Count().ToString())
End Using
End Using
hrm interesting ... thats basically what i have ... hrm...