Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 String or binary data would be truncated.

Author  Topic 

pallavikris2
Starting Member

4 Posts

Posted - 2005-03-02 : 02:34:11
i have created table in MS Access. and accessing it with c#.NET.
iam getting this error while trying to update the data.
inserting and deleting is done clearly.
i have checked the filed lengths and data types.
i will be thankfull for any help in solving this problem.
thanks,
pallavi

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-02 : 12:23:28
well one of your input values is larger that the one in your tables.
does it tell you which one?

Go with the flow & have fun! Else fight the flow
Go to Top of Page

pallavikris2
Starting Member

4 Posts

Posted - 2005-03-02 : 23:11:03
no, it doesnt tell me which input value. But i have checked every textbox value, ( by printing Textbox.text.length) no value is larger than the column length in the table.
thanx for considering my problem.
Pallavi
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-03 : 11:16:11
are you using stored procedures?
check the parameter length of the sqlcommand parameter property.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

pallavikris2
Starting Member

4 Posts

Posted - 2005-03-04 : 00:33:08
iam not using any stored procedures.
update comand which iam using is ,

oleDbDataAdapter1.UpdateCommand=new OleDbCommand("update PersonalDetails set FirstName ='" +txbFname.Text + "', " +" LastName = '" +txbLname.Text +"',"+" City='"+txbCity.Text +"',"+" Phone='" + Convert.ToInt32(txbPhone.Text) +"', "+" EmailID='" + txbEmail+ "' where PersonalID = '" + Convert.ToInt32(txbId.Text)+ "'",cnn);

oleDbDataAdapter1.UpdateCommand.Parameters.Add("txbFname.text",OleDbType.VarChar,20,"FirstName");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("txbLname.text",OleDbType.VarChar,20,"LastName");and others in the same way.
and the table(PersonalDetails) has, PersonalID-varchar(10), FirstName-Varchar(20),LastName-varchar(20), City-varchar(20),Phone-varchar(20),EmailID-varchar(50)

Thanx,
Pallavi
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-04 : 05:56:02
why are you even adding paramteres when you don't use then anywhere??

Go with the flow & have fun! Else fight the flow
Go to Top of Page

pallavikris2
Starting Member

4 Posts

Posted - 2005-03-04 : 06:03:23
iam new to the c#.net and i thought it is must to add parameters to update command. can u plz tell me how the update command works ? and in which conditions i should use the parameters.
thanks & regrds
pallavi
Go to Top of Page
   

- Advertisement -