Click here to Skip to main content
15,911,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
string or binary data would be truncated. the statement has been terminated.
how to solve this problem..........
Posted
Comments
Maciej Los 3-Jul-13 7:16am    
Please, share the code and provide more details. Use "Improve question" widget.
arvindnitin7 3-Jul-13 7:17am    
this is my sql query...........
INVOICE_EXC_DUTY1 VARCHAR(20),
INVOICE_E_CESS1 VARCHAR(20),
INVOICE_SHE_CESS1 VARCHAR(20),
INVOICE_TOTAL1 VARCHAR(20),
INVOICE_TAX1 VARCHAR(20),
INVOICE_A_TAX1 VARCHAR(20),
INVOICE_G_TOTAL VARCHAR(20),
INVOICE_EXC_WORDS VARCHAR(20),
INVOICE_G_WORDS VARCHAR(20),
INVOICE_TOTAL VARCHAR(20),

INVOICE_ADD VARCHAR(500),
INVOICE_PH_NO VARCHAR(20),
INVOICE_TIN VARCHAR(50),
INVOICE_ECC VARCHAR(50),
INVOICE_RANG VARCHAR(50),
INVOICE_DIV VARCHAR(50),
INVOICE_COMM VARCHAR(50),

INVOICE_QTY1_TOTAL VARCHAR(20),
INVOICE_QTY2_TOTAL VARCHAR(20)

and this is coading...................
"insert into INVOICES (INVOICE_EXC_DUTY1,INVOICE_E_CESS1,INVOICE_SHE_CESS1,INVOICE_TOTAL1,INVOICE_TAX1,INVOICE_A_TAX1,INVOICE_G_TOTAL,INVOICE_EXC_WORDS,INVOICE_G_WORDS,INVOICE_ADD,INVOICE_PH_NO,INVOICE_TIN,INVOICE_ECC,INVOICE_RANG,INVOICE_DIV,INVOICE_COMM,INVOICE_QTY1_TOTAL,INVOICE_QTY2_TOTAL)
values
('" + INVOICE_EXC_DUTY1.Text + "','" + INVOICE_E_CESS1.Text + "','" + INVOICE_SHE_CESS1.Text + "','" + INVOICE_TOTAL1.Text + "','" + INVOICE_TAX1.Text + "','" + INVOICE_A_TAX1.Text + "','" + INVOICE_G_TOTAL.Text + "','" + INVOICE_EXC_WORDS.Text + "','" + INVOICE_G_WORDS.Text + "','" + INVOICE_ADD.Text + "','" + INVOICE_PH_NO.Text + "','" + INVOICE_TIN.Text + "','" + INVOICE_ECC.Text + "','" + INVOICE_RANG.Text + "','" + INVOICE_DIV.Text + "','" + INVOICE_COMM.Text + "','" + INVOICE_QTY1_TOTAL.Text + "','" + INVOICE_QTY2_TOTAL .Text+ "')";
Thanks7872 3-Jul-13 7:21am    
Dont paste code like this.Use Improve question widget in your question above.
ArunRajendra 3-Jul-13 7:22am    
Can you give the data that you are passing i.e. what is the value you are entering in INVOICE_EXC_DUTY1. You need to give this info for all.
jaideepsinh 3-Jul-13 8:00am    
Check you field's data type in table and datatype of your data's which you are passing may be they don't match and one of the reason to generate error.

1 solution

One of INVOICE_EXC_DUTY1.Text(),INVOICE_E_CESS1.Text(),INVOICE_SHE_CESS1.Text(),INVOICE_TOTAL1.Text(),INVOICE_TAX1.Text(), INVOICE_A_TAX1.Text(, INVOICE_G_TOTAL.Text(), INVOICE_EXC_WORDS.Text(), INVOICE_G_WORDS.Text(), INVOICE_PH_NO.Text() is greater than 20 characters
OR
one of INVOICE_TIN.Text(),INVOICE_ECC.Text(),INVOICE_RANG.Text(),INVOICE_DIV.Text(),INVOICE_COMM.Text(),INVOICE_QTY1_TOTAL.Text(),INVOICE_QTY2_TOTAL.Text() is greater than 50 characters
OR
INVOICE_ADD.Text() is greater than 500 characters

You haven't supplied the data that you are passing to the statement so we can't tell you exactly which one.

You can truncate the data before passing it into this statement (example of how to do that here[^])
or you can (and should) validate the content before you get to this point.

Lastly, this is a bad way to format an insert statement - read up on sql injection[^]
 
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