Value violates the MaxLength - from combo box

  • Thread starter Thread starter CAM
  • Start date Start date
C

CAM

Hello,

I am using Visual Studio 8 (Visual Basic.Net) Within my form I have a
combo box called "cboState" the data is pick up from another table call
"tblState" containing the following fields "State_Name" (i.e. California,
Nevada) and the other field is call "State" (i.e. AZ, CA, etc). It seems
to work fine, but when I select a state I get this error message - "Cannot
set column 'State'. The value violates the MaxLength limit of this column".
Now the fields from both tables "tblState" and the actual table from the
form (tblUnAssigned) fields have the same data field type nvarchar(6). I
only selecting the state abbreviation from the combo box and I know I bind
and put the "Display Member", "Value Member", and "Selected Member"
correctly. I just can't figure it out. Can somebody help me on this? I
tired to look in the Internet, but no success. I even set the length on
both fields of their respective table to nvarchar(MAX), but that did not
worked. Thank you in advance.

cheers,
 
Cam,

It needs only three rows of code to populate a combobox.

Will you show that to us, it seems to me that you have used a wrong property
to populate the valuemember.

In fact you show it wrong to us.

Cor
 
Thanks for responding and I appreciate your help. In the form I have a
combo box, which the user selects a state. This combo box looks up the
states in a table called "tblState", which has two fields. Field 1 -
"State_Name" has full name of all states (i.e, Arizona, Califoria, Florida,
etc) this is what I want the user to see when he or she is selecting the
state. The second field is called "StateCode" an abbreviation of the
states, which has the value I want inputed into the combo box (i.e. AZ, CA,
FL, etc). When the user scrolls to another record or previous record they
will see the combo box value as "CA" or "FL" or whatever state was inputted.
The field for the combo box is called "State" from the query called
"Unassigned" an updated query. The user should have the value "AZ" or "CA",
or "FL" or whatever is in the "State" field.

This is what I have in the Data Binding Mode in the combo box:
Data Source: TblStatesBindingSource
Display Member: "State_Name"
Value Member: "State_Code"
Select Value: QryUnassignedBindingSource - State

Now if I replace the Display Member with "State _Code" instead of
"State_Name" it works fine I don't get any error message, but the whole
point is to show the state names (i.e. Arizona, California, Hawaii, etc) and
have the value of the "State_Code" (i.e. CA, FL, etc) inputted into the
combo box. I just don't know why I am getting the "Cannot set column
'State'. The value violates the MaxLength limit of this column". Again,
I appreciate any help. Thank you in advance.

Cheers
 
Hi, i am having the exact same problem, see what i discovered and then you can test it your self.

It seems that the control is binding the display member, that means that its trying to insert the description in the bd not the code, and the description is too large, try altering the table, and your data set so that the length could containt the whole description, commit your update and go query your bd, the value that was written should be your description not your code. This is not correct, i am fighting with this exact same problem, any solution mail me

This will not solve your problem but that seems to be the problem.



CAM wrote:

Thanks for responding and I appreciate your help.
27-Dec-08

Thanks for responding and I appreciate your help. In the form I have a
combo box, which the user selects a state. This combo box looks up the
states in a table called "tblState", which has two fields. Field 1 -
"State_Name" has full name of all states (i.e, Arizona, Califoria, Florida,
etc) this is what I want the user to see when he or she is selecting the
state. The second field is called "StateCode" an abbreviation of the
states, which has the value I want inputed into the combo box (i.e. AZ, CA,
FL, etc). When the user scrolls to another record or previous record they
will see the combo box value as "CA" or "FL" or whatever state was inputted.
The field for the combo box is called "State" from the query called
"Unassigned" an updated query. The user should have the value "AZ" or "CA",
or "FL" or whatever is in the "State" field

This is what I have in the Data Binding Mode in the combo box
Data Source: TblStatesBindingSourc
Display Member: "State_Name
Value Member: "State_Code
Select Value: QryUnassignedBindingSource - Stat

Now if I replace the Display Member with "State _Code" instead of
"State_Name" it works fine I don't get any error message, but the whole
point is to show the state names (i.e. Arizona, California, Hawaii, etc) and
have the value of the "State_Code" (i.e. CA, FL, etc) inputted into the
combo box. I just don't know why I am getting the "Cannot set column
'State'. The value violates the MaxLength limit of this column". Again,
I appreciate any help. Thank you in advance

Cheer




Previous Posts In This Thread:

Value violates the MaxLength - from combo box
Hello

I am using Visual Studio 8 (Visual Basic.Net) Within my form I have a
combo box called "cboState" the data is pick up from another table call
"tblState" containing the following fields "State_Name" (i.e. California,
Nevada) and the other field is call "State" (i.e. AZ, CA, etc). It seems
to work fine, but when I select a state I get this error message - "Cannot
set column 'State'. The value violates the MaxLength limit of this column".
Now the fields from both tables "tblState" and the actual table from the
form (tblUnAssigned) fields have the same data field type nvarchar(6). I
only selecting the state abbreviation from the combo box and I know I bind
and put the "Display Member", "Value Member", and "Selected Member"
correctly. I just can't figure it out. Can somebody help me on this? I
tired to look in the Internet, but no success. I even set the length on
both fields of their respective table to nvarchar(MAX), but that did not
worked. Thank you in advance

cheers,

Cam,It needs only three rows of code to populate a combobox.
Cam

It needs only three rows of code to populate a combobox

Will you show that to us, it seems to me that you have used a wrong property
to populate the valuemember

In fact you show it wrong to us

Co


Thanks for responding and I appreciate your help.
Thanks for responding and I appreciate your help. In the form I have a
combo box, which the user selects a state. This combo box looks up the
states in a table called "tblState", which has two fields. Field 1 -
"State_Name" has full name of all states (i.e, Arizona, Califoria, Florida,
etc) this is what I want the user to see when he or she is selecting the
state. The second field is called "StateCode" an abbreviation of the
states, which has the value I want inputed into the combo box (i.e. AZ, CA,
FL, etc). When the user scrolls to another record or previous record they
will see the combo box value as "CA" or "FL" or whatever state was inputted.
The field for the combo box is called "State" from the query called
"Unassigned" an updated query. The user should have the value "AZ" or "CA",
or "FL" or whatever is in the "State" field.

This is what I have in the Data Binding Mode in the combo box:
Data Source: TblStatesBindingSource
Display Member: "State_Name"
Value Member: "State_Code"
Select Value: QryUnassignedBindingSource - State

Now if I replace the Display Member with "State _Code" instead of
"State_Name" it works fine I don't get any error message, but the whole
point is to show the state names (i.e. Arizona, California, Hawaii, etc) and
have the value of the "State_Code" (i.e. CA, FL, etc) inputted into the
combo box. I just don't know why I am getting the "Cannot set column
'State'. The value violates the MaxLength limit of this column". Again,
I appreciate any help. Thank you in advance.

Cheers







Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET A Short Synopsis of ViewState
http://www.eggheadcafe.com/tutorial...7f4-98e22fa3a34c/aspnet-a-short-synopsis.aspx
 
Now if I replace the Display Member with "State _Code" instead of
"State_Name" it works fine I don't get any error message, but the whole
point is to show the state names (i.e. Arizona, California, Hawaii, etc)
and
have the value of the "State_Code" (i.e. CA, FL, etc) inputted into the
combo box. I just don't know why I am getting the "Cannot set column
'State'. The value violates the MaxLength limit of this column". Again,
I appreciate any help. Thank you in advance.

Seems to work fine here...

Have you tried to create a brand new project to see if you have the same
behavior ? IMO you won't and it's likely you have something in your current
project that causes this behavior such as some unnoticed incorrect
binding...
 
No not a bug, wrong way of setting and using the properties in a combobox.

That is not a bug in VB that is a bug in your program.

The described usage it 100000 times used as sample for the combobox.

Cor

in message
 
Try setting the comboBox's property "(databindings) > Text" to none.

To be clear: the properties of the comboBox will have a (databindings) section, under which there is a text field. The databinding's text field needs to be cleared out.

If anyone could elaborate on the WHY, i'd appreciate it :)
Hello,

I am using Visual Studio 8 (Visual Basic.Net) Within my form I have a
combo box called "cboState" the data is pick up from another table call
"tblState" containing the following fields "State_Name" (i.e. California,
Nevada) and the other field is call "State" (i.e. AZ, CA, etc). It seems
to work fine, but when I select a state I get this error message - "Cannot
set column 'State'. The value violates the MaxLength limit of this column".
Now the fields from both tables "tblState" and the actual table from the
form (tblUnAssigned) fields have the same data field type nvarchar(6). I
only selecting the state abbreviation from the combo box and I know I bind
and put the "Display Member", "Value Member", and "Selected Member"
correctly. I just can't figure it out. Can somebody help me on this? I
tired to look in the Internet, but no success. I even set the length on
both fields of their respective table to nvarchar(MAX), but that did not
worked. Thank you in advance.

cheers,
On Saturday, December 27, 2008 1:54 AM Cor Ligthert[MVP] wrote:
Cam,

It needs only three rows of code to populate a combobox.

Will you show that to us, it seems to me that you have used a wrong property
to populate the valuemember.

In fact you show it wrong to us.

Cor

news:[email protected]...
 
Back
Top