.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

converting datatable data to arraylist

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :ASP.Net
hi friends pl tell me how  to convert datatable data to arraylistthanks in advance

View Complete Post

More Related Resource Links

Data Points: DataSet and DataTable in ADO.NET 2.0


ADO. NET 2. 0 sports some exciting enhancements to the core classes found in ADO. NET 1. x and introduces a variety of new classes, all of which promise to improve performance, flexibility, and efficiency.

John Papa

MSDN Magazine November 2005

Error converting data type varchar to numeric.


I create a form to record data using ASP.NET and SQL database...
when i run the project show error "Error converting data type varchar to numeric"

what's the problem actually.i try to change in datatype in database..
but still showing error...


How to handle null while converting from my datatable to List<> using LINQ


I am converting my datatable to LISt using LINQ
how do I handle nulls coming from database

List<Port> portDetails = new List<Port>();
DataTable dt = ds.Tables[0];               
portDetails = (from q in dt.AsEnumerable()
select new Port
PortCode = q.Field<string>("Code"),
ExtCode = q.Field<string>("Nb"),
Name = q.Field<string>("Name"))

In the above query if Code is null I do not want property
portcode to be set to the value it should only set if it is
not null or not blank 
PortCode = q.Field<string>("Code"),

What should be syntax
I was trying somethign like this which doesnt work
Portcode = q.Field<bool>("Code") == null ? null : q.Field<bool>("Code")


Conversion Failed when Converting the nvarchar value 'N' to data type int.

Hi.. I am facing a strange situation. when i executing the following query it is returning the error SELECT  s.row_id as shipment,    SUM(CAST(la5.attr_value AS INT)) AS Cases     FROM    shipment s WITH(NOLOCK)    INNER JOIN shipping_shift ss WITH(NOLOCK) ON s.shipping_shift = ss.row_id    INNER JOIN shift WITH(NOLOCK) ON ss.shift_id = shift.shift_id    INNER JOIN shipment_lot sl WITH(NOLOCK) ON s.po_id = sl.po_id AND s.cust_id = sl.cust_id AND          s.so_line_no = sl.so_line_no and s.ship_date_local = sl.ship_date_local     INNER JOIN lot_attr la5 WITH(NOLOCK) ON sl.lot_no = la5.lot_no AND sl.item_id = la5.item_id AND la5.attr_id = (SELECT attr_id FROM attr WITH(NOLOCK) WHERE attr_desc = 'CaseQty' AND attr_grp = 3)  WHERE s.spare2 = 'RELEASED'       AND shift.shift_desc = 'c'   AND DAY(ss.production_date) = DAY('2010-08-09 00:00:00.000')    AND MONTH(ss.production_date) = MONTH('2010-08-09 00:00:00.000')    AND YEAR(ss.production_date) = YEAR('2010-08-09 00:00:00.000') GROUP BY s.row_id  Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the nvarchar value 'N' to data type int. The column  type of attr_value of lot_attr table is a USER D

Binding DataTable data to ObjectDataSource

Hi all, I am trying to bind a DataTable into a ObjectDataSource. This ObjectDataSource data will be used to bind into my LocalReport in ReportViewer. I have already successfully binded my data into the DataTable. My problem now is how do i bind the data in my DataTable into the ObjectDataSource so that it can be used in my report? Here is my current codes: ASPX:<rsweb:ReportViewer ID="ReportViewer1" runat="server"> <LocalReport ReportPath="Modules\Report.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:ObjectDataSource runat="server" ID="ObjectDataSource1"> </asp:ObjectDataSource> VB:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try Dim dtable As DataTable = SetReportDataSource() If dtable.Rows.Count > 0 Then Dim rds As New ReportDataSource() ReportViewer1.LocalReport.DataSources.Clear() ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Data

Miss lines when converting data from TXT to sql

I have several txts files in a folder and I am trying to convert those into my sql database.  There is no error message during the conversion however, it misses converting some lines in my txt. It was showing that the total line number of the txt file was 8644 however after inserting into database, only 8631 shows up. I am so confused how can this happen? For example,   [Flat File Source [1]] Information: The total number of data rows processed for file "E:\My_Txts\20093347.txt" is 8742.  [Flat File Source [1]] Information: The processing of file "E:\My_Txts\20093347.txt" has ended.  and then it shows [DTS.Pipeline] Information: "component "OLE DB Destination" (9)" wrote 8730 rows. 

How to remove data from arrayList with Linq?

Hi All-This arrayList produced by the Linq query returns data pairs of an ID and count.  I would like to keep pairs that have a high enough count.  For example, keep all that have a count of 5 and higher so if the arraylist contains:userID    Count1               102               93                94                35                1the remaining data in the arraylist would be userId 1,2, and 3 (with their counts).  How can I do this? Dim customerCount = (From c In results Group c By key = c.userID Into Group _ Select New With _ { _ .userID = key, _ .Count = Group.Count() _ } _ ).ToList().OrderByDescending(Function(a) a.Count)

Error converting data type nvarchar to numeric.

i create a form using form view tools in asp.net..when i click insert command it shows error..this is code which i use for InsertCommand:<asp:SqlDataSource ID="SqlDataSourceFormView" runat="server"         ConnectionString="<%$ ConnectionStrings:AED_PanasonicConnectionString2 %>"         SelectCommand="SELECT * FROM [Debtor]"        InsertCommand="INSERT INTO Debtor (CompanyName, Desc2, RegisterNo, Address1, Address2, Address3, Address4, PostCode)VALUES (@CompanyName, @Desc2, @RegisterNo, @Address1, @Address2, @Address3, @Address4, @PostCode)">        </asp:SqlDataSource>Error:-Error converting data type nvarchar to numeric.where i have to make changes?

Arithmetic overflow error converting expression to data type smallint

Can anyone tell me what exactly this means? Arithmetic overflow error converting expression to data type smallint. 

Error converting data type nvarchar to datetime.

hi all, I simply explain my application.plz try to understand. In my applicationi want to generate one complaint id.one customer may give two or more complaints at a time.suppose,he give two or more pnr numbers and their status and prioirty may differs.for this complaint i need to generate one common complaint id.how it is possible..?with some constant rows. am getting error in Class File near CLUser_Logged_DTClass File using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Web.Configuration; /// <summary> /// Summary description for BalComplaints /// </summary> public class BalComplaints { public BalComplaints() { // // TODO: Add constructor logic here // } int SNo, Complaint_Type_ID, Caller_Type_ID, No_of_Articles, Article_ID, CLPriority_ID, Status_ID, Origin_ID, Destination_ID; public int SNo1 { get { return SNo; } set { SNo = value; } } public int Caller_Type_ID1 { get { return Caller_Type_ID; } set { Caller_Type_ID = value; } } public int Destination_ID1 { get { return Destination_ID; } set { Destination

how to Input data from textbox to unknown size of array or arraylist?


I am fresh to asp.net. I m using vb to write it. Could someone who is professional guide me?

I want to input data from textbox to "unknown size" array or arraylist, and bind it to gridview.

I have more than 1 data to input. Do i need to use loop to bind?

Thank you for your kind attention and patient.

DataTable to a binary field on data base



Is it possible to convert a datatable into binary data and save it into on a binary field on database?

Error converting data type varchar to numeric



I am trying to execute below query.



CAST('123,456,789.00' AS DECIMAL(11,2))

System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value 'Cash' to


Line 64:         CMD = New SqlCommand(SQL, CON)
Line 65:         CMD.Parameters.Add("@payment", SqlDbType.VarChar, 50).Value = payment.Text.Trim
Line 66:         CMD.ExecuteNonQuery()
Line 67:
Line 68:

Hi All,

I'm having the above mentioned error message.

Please help.






SSIS converting Blank data to '30-DEC-99'

I am importing data from a flat file using SSIS 2005. Everything runs fine but I see blank values in source date columns getting converted to '30-DEC-99' in oracle.



Openquery - truncation problem (converting data from Oracle 10g to SQL 2005)


I am having problems with data truncating when inserting into a SQL 2005 db from Oracle 10g- using openquery and a linked server.   For instance, if I run something like:

insert dbo.CWDocumentStaging
select * from openquery(LK_Snomass,'select RSFORM.REPRESENTATION as REPRESENTATION

The results of the blob data are only 202 hexademical characters in length.  And then when I convert it to varchar, the results are cut-off.  For instance, on a particular test record that I converted, here is what I have in the SQL database (using):

select convert(varchar(max), DOCUMENT_TEXT), DOCUMENT_TEXT from dbo.CWDocumentStaging

I get the following:

for Document_Text, I get the following:


then for convert(varchar(max), DOCUMENT_TEXT):

this old man, he played one, he played knick-knack on my thumb with a knick-knack paddy whack give a

If I insert the data running the query against the linked server directly, the data does not truncate

Error converting data type nvarchar to numeric in Store Procedure execution



When I execute a Store Procedure via 'EXEC sp_XXX @p1, @p2' I'm getting this error 'Error converting data type nvarchar to numeric'.

After diggin into the TSQL code I have found that there's a field (type: nvarchar(200)) breaking the execution and resulting on the error.

If I query the table and the specified field with the same parameters as the Store Procedure the results are ok! If I execute the same code as the Store Procedure with the same parameters values the results are ok. The error only happens when executing the Store Procedure.

Any idea ?

Thanks in advance,

Gustavo Brian


If I cast the field to a smaller size value, as nvarchar(80), it works, but of course with data truncation.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend