Strongly-typed reading values from CSV DataTable
Is there a way to do this using parameters so the value is automatically converted to whatever datatype the keyfield has in the datatable?This code should be reusable for future bulk update...
View ArticleAnswer by Saeed for Strongly-typed reading values from CSV DataTable
A few comments:This method does way too much. It is difficult to understand and will be difficult to debug and maintain. Break it down into smaller methods that each have a single responsibility.Use...
View ArticleAnswer by Mongus Pong for Strongly-typed reading values from CSV DataTable
Yup, that method does definitely need breaking down into smaller pieces.You may like to use an iterator method to loop through the lines. Something along the lines of :IEnumerable<string>...
View ArticleAnswer by Brian Reichle for Strongly-typed reading values from CSV DataTable
Just one small comment in addition to those provided by Saeed and Mongus, you have defined a constant called CSVKEYFIELDNAME but in the only place it is (shown to be) used, you call ToLower() on it....
View ArticleAnswer by Andris for Strongly-typed reading values from CSV DataTable
Is there a way to do this using parameters so the value is automatically converted to whatever datatype the keyfield has in the datatable?You could use something like this:object csvKeyValue =...
View ArticleAnswer by Sjoerd for Strongly-typed reading values from CSV DataTable
I noticed this code: parameters.DataTableOriginal.Select(DBKEYFIELDNAME +"='"+ csvKeyValue.ToString() +"'"). Just putting quotes around an user-input screams SQL Injection to me.The problem is that...
View ArticleAnswer by Nick Udell for Strongly-typed reading values from CSV DataTable
Prefer var in for loop variable initializers:for (int i = 1; i <= csvLines.Length - 1; i++)Should befor (var i = 1; i <= csvLines.Length - 1; i++)
View Article