|
-
Sep 16th, 2009, 09:15 PM
#1
DataCol problems?
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
-
Sep 16th, 2009, 09:20 PM
#2
Re: DataCol problems?
Did you set the MaxLength Property. MSDN says that
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.
Please mark you thread resolved using the Thread Tools as shown
-
Sep 16th, 2009, 10:04 PM
#3
Re: DataCol problems?
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
-
Sep 16th, 2009, 10:28 PM
#4
Re: DataCol problems?
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.
-
Sep 17th, 2009, 01:33 AM
#5
Re: DataCol problems?
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
Last edited by i00; Sep 17th, 2009 at 01:40 AM.
-
Sep 17th, 2009, 01:39 AM
#6
Re: DataCol problems?
 Originally Posted by i00
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
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.
-
Sep 17th, 2009, 01:43 AM
#7
Re: DataCol problems?
it does it when i call the .count on that enum actually so
vb 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
-
Sep 17th, 2009, 02:00 AM
#8
Re: DataCol problems?
I just tried the following code, with and without the highlighted line, and it worked fine for me.
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
There's obviously something else at play in your case.
-
Sep 17th, 2009, 03:23 AM
#9
Re: DataCol problems?
hrm interesting ... thats basically what i have ... hrm...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|