none
String or binary data would be truncated. The statement has been terminated.

    Question

  • hi all

      i am inserting data to database from text file,when i reach the line "adapter.Update(dataset,tablename)" i am getting this error.. please help me out!!!

    please!!

    newdata=filecontent.ToArray();
                        values = new object[newdata.Length];
                        for (int k = 0; k < newdata.Length; k++)
                            {
                                Type type = dataSet.Tables[0].Columns[k].DataType;
                                if (newdata[k] == "NULL" )
                                  values[k] = DBNull.Value;
                              else if (type == typeof(bool))
                                  values[k] = Convert.ToBoolean(int.Parse(newdata[k]));
                                
    
                                
                            else
                                //values[k] = Convert.ChangeType(newdata[k], type);
                        values[k] = Convert.ChangeType(newdata[k], dataSet.Tables[0].Columns[k].DataType);
                    
                                }
                              //dt.Rows.Add(values);
    
                       // dataSet.Tables[0].Rows.Add(filecontent.ToArray());
                                dataSet.Tables[0].Rows.Add(values);
    
                        adapter.Update(dataSet, tablename);
    
    
                    }

    thanks

    Selva

    Saturday, June 23, 2012 6:47 AM

Answers

All replies