0

I receive an error when trying to insert data into the Datatable.

Error: String or binary data truncated ---Here adapt.Fill(dt);

 dt = new DataTable();
            con = new SqlConnection(cs);
            con.Open();
            adapt = new SqlDataAdapter(@"CREATE TABLE #mytemptable (  
Metric_Name varchar(100),  
SOW_Baseline varchar(30),
CurrentStatus_Time varchar(300),
LoggedTime DateTime)
declare @Product varchar(300)
set @Product='" + DropDownList1.SelectedValue + @"'
declare @Customer varchar(300)
set @Customer='" + ((DropDownList)PlaceHolder1.FindControl("DDLCust")).SelectedValue + @"'  
-- insert some data into it 
insert into #mytemptable  
-----select queries

-- view the data  
select * from #mytemptable  

-- drop the table if you want to  
drop table #mytemptable  ", con);

                adapt.Fill(dt);
Leena
  • 9
  • 1
  • What is your question? do you not understand what the error means? – Scott Chamberlain Aug 14 '17 at 05:58
  • the table you created is not matching to the data you are inserting. Eg: your table have a column Metric_Name with size 100, but the data you are inserting to the table might have a value for that column with size bigger than 100. – Sin Aug 14 '17 at 06:14

0 Answers0