Frage

I currently have a working program that is giving me a harmless but annoying error at runtime. I have a DataGridView that displays select contents of an SQL table, which currently only contains one entry. I have a column in that table called 'Notes' that is designed to be a relatively large storage space for text data; the user needs to be able to type out and store detailed notes in a single textbox field. The entry in that column for my one record is (according to Word) 690 characters in length (with spaces), but I receive an error when viewing my DataGridView that claims the column exceeds the MaxLength limit. I have manually set that limit (the MaxInputLength property) during design time to be 2147483647, which is obviously very far above 690, but the error persists.

I'm not sure what my DGV's problem is because 690 characters is hardly a big deal storage-wise. Could somebody point me to the underlying issue with this error? Thanks in advance!

War es hilfreich?

Lösung 2

It turns out that the culprit behind this error was a lack of communication between my program's dataset and the actual database. When I initially received the error, I left the text data I had entered in the database, changed the size allowance for the row in the DataGridView, and rebuilt my program. However, the dataset did not update to reflect the size change- communication had been shut down between the dataset and the database because the error had already happened. In other words, the dataset didn't update itself in order to 'protect' itself (even though that wasn't necessary).

I resolved the issue by rebinding my DGV in the designer. I set my DGV's data source property to none, deleted the three adapters that came with the connection, and deleted my old dataset. After everything was clear, I remade the data connection (using the same connection string) and the error had disappeared. I hope this helps anybody that runs into the same issue- those DGVs are sneaky.

Andere Tipps

Go onto the dataset and change the fields maxLength property. This manually overrides the datasets out of date information. This does not require lost of table configuration.

when creating the "Notes" column what type did you specify for it to use.
I myself use varChar(maxStringLenth)

Also to able to help you more efficiently can you provide some more technical info about your dataGrid and DataBase

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top