Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi there ,

I have bank table in my sql database, field(column) called 'code' length is 4(chr).
All banks are in loaded combo box and select relevant bank from entry screen.

I am selecting bank from combo list in my entry form which is linked to employee master table which has field(column) called 'bank' length is 4(chr).

all combo binding and selecting working

when click save button, it give error
"Cannot set column 'bank'. The value violates the MaxLength limit of this column."

my save button code as follows

private void button3_Click(object sender, EventArgs e)
{
this.Validate();
this.masterBindingSource.EndEdit();
this.masterTableAdapter.Update(this.timeattDataSet.master);
this.tableAdapterManager.UpdateAll(this.timeattDataSet);
this.timeattDataSet.AcceptChanges();
}


Please help me

Ajith

What I have tried:

private void button3_Click(object sender, EventArgs e)
{
this.Validate();
this.masterBindingSource.EndEdit();
this.masterTableAdapter.Update(this.timeattDataSet.master);
this.tableAdapterManager.UpdateAll(this.timeattDataSet);
this.timeattDataSet.AcceptChanges();
}
Posted
Updated 8-Apr-20 3:27am
Comments
[no name] 24-Apr-17 9:54am    
Not sure what you think we can help you with. The error message is perfectly clear.

The error message is pretty explicit:
Cannot set column 'bank'. The value violates the MaxLength limit of this column.
The column called bank has been defined as having a specific maximum number of characters - perhaps the default 50 - and the value you are trying to INSERT or UPDATE to the DB exceeds that length.

We can't fix that: you need to either find a way to truncate or limit the length of the data you are passing to SQL, or change the DB table design to allow longer entries in that column.
 
Share this answer
 
Comments
Member 12931315 24-Apr-17 10:56am    
Hi
Thanks for quick reply,in my master table bank column length number of characters is 4 so is the support table bank has same number of characters, why I have to go 50 as code value is simply like this '7280', can you elaborate on that.

Thank again for help

Ajith
OriginalGriff 24-Apr-17 11:06am    
You don't - but something you are inserting is longer than four characters.
As I said: either find a way to truncate or limit the length of the data you are passing to SQL, or change the DB table design to allow longer entries in that column.
If your bank is supposed to be four characters, you need to look at your data and find out what exactly you are putting in there that is longer, and then find out why. We can't do that for you - we don;t have any access to your data or your inputs!
Member 12931315 24-Apr-17 13:18pm    
Hi
Thanks for help,what I did was redesigned combo box and tried and problem got
solved but I found another though while in Visual studio design mode, it shows
as saved and going one record to another and coming data are there.

but when I exit Visual studio and run query from Microsoft sql server tool
for that table those new data is not there.

Have any idea why is that,is Visual studio maintain mirror in working directory

your help much appreciated

Ajith
OriginalGriff 24-Apr-17 14:02pm    
Without your code, and all your data? No, we can't tell you.
Start by looking at how you connect to the DB. Chances are you've connected to the wrong DB, or you attached a copy that VS is configured to overwrite.
You did nothing wrong this is a common problem with Winforms combo boxes. If you look in the Form.Designer.vb, search for the control in the definition you will see two add statements comment out the first and your code should work. I have reported this issue to NSDN but it has not been fixed as of the latest release.

        'SL_OperatorComboBox
        '
        'Me.SL_OperatorComboBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.Shift_LogBindingSource, "SL_Operator", True))
        Me.SL_OperatorComboBox.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.Shift_LogBindingSource, "SL_Operator", True))
        Me.SL_OperatorComboBox.DataSource = Me.OperatorsBindingSource
        Me.SL_OperatorComboBox.DisplayMember = "Name"
        Me.SL_OperatorComboBox.FormattingEnabled = True
        Me.SL_OperatorComboBox.Location = New System.Drawing.Point(158, 81)
        Me.SL_OperatorComboBox.Name = "SL_OperatorComboBox"
        Me.SL_OperatorComboBox.Size = New System.Drawing.Size(150, 21)
        Me.SL_OperatorComboBox.TabIndex = 31
        Me.SL_OperatorComboBox.ValueMember = "Initials"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900