String or binary data would be truncated exception?
问题 cmd = new SqlCommand("INSERT INTO sms_sentmessages(Mobilefrom,Mobileto,Message,senddate) VALUES('" + str.Substring(0, str.Length - 4).ToString() + "','" + number + "','" + txtmessage.Text.Replace("'", "''").Trim() + "',getdate())", con); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); 回答1: str.Substring(0, str.Length - 4) and/ or txtmessage.Text.Replace("'", "''").Trim() are too large to fit with the column you're trying to insert into. 回答2: Well, presumably you're trying to insert