Click here to Skip to main content
15,886,676 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
public void pripass2()
        {
            float  b = 0.5f;
            float  c;
            ppass = Convert.ToSingle (label19.Text);
            try
            {
                if (ppass > 0 && checkBox5.Checked == true)
                {
                    ppass--;
                    label19.Text = ppass.ToString();
                    cmd = new MySqlCommand();
                    cmd.CommandText = "update emppassdetails set activepass='" + label19.Text + "'";
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();

                }
                else if (ppass > 0 && checkBox5.Checked == false)
                {
                    c = ppass - b;
                    label19.Text = c.ToString();
                    cmd = new MySqlCommand();
                    cmd.CommandText = "update emppassdetails set activepass='" + label19.Text + "'";
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();

                }
            
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please Call Anurag"+ex.Message );
            }
        }


Here PPASS IS declared globally and other variables are local but elseif statement is giving error and if statement is working fine
Data Truncated for column activepass at row 1
Posted
Comments
Mohibur Rashid 31-Aug-12 4:35am    
where is the condition or limit in your update sql? besides what is the length of activepass in your database?
[no name] 31-Aug-12 4:37am    
how to give that please guide me

hi friend you should read this,

The problem is that those empty values are interpeted as empty strings (''), not as NULL values. 

To force a NULL value into those fields you can change your text-file and use the escape character "\N".


http://stackoverflow.com/questions/1704304/what-is-this-error-database-query-failed-data-truncated-for-column-column-na[^]


http://dba.stackexchange.com/questions/4091/data-truncated-for-column[^]

see this Example:

SQL
mysql> create table a (a float not null);
Query OK, 0 rows affected (0.11 sec)

mysql> insert a values ('');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'a' at row 1 |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)

mysql> set sql_mode = 'STRICT_ALL_TABLES';
Query OK, 0 rows affected (0.02 sec)

mysql> insert a values ('');
ERROR 1265 (01000): Data truncated for column 'a' at row 1


regards
sarva
 
Share this answer
 
v4
Comments
[no name] 31-Aug-12 4:55am    
can u give me some more examples please
Sarrrva 31-Aug-12 5:20am    
otherwise Refer this Link:
http://www.desknow.com/kb/idx/11/175/article/
Sarrrva 31-Aug-12 5:14am    
post your table structure onurag
[no name] 31-Aug-12 5:43am    
CREATE TABLE `emppassdetails` (
`pfno` varchar(20) default NULL,
`activepass` float default '0',
`blockedpass` float default '0',
`borrowedpass` float default '0',
`activepto` float default '4',
`blockedpto` float default '0',
`borrowedpto` float default '0',
`activeschoolpass` float default '3',
`year` int(11) default NULL,
`approved` varchar(5) default 'no'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Sarrrva 31-Aug-12 5:53am    
activepass is a float data type, please correct Your Query Syntax or don't try to store Empty String etc.....


Write your command text like this

"update emppassdetails set activepass=" + Convert.toDecimal(label19.Text) + "";
Data Truncate for the column (eg: id) error :
Answer: Check Your Data Type weather it support Varchar ()

Regards
SHEIK ANAS
 
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