On Thu, Jan 15, 2009 at 11:00 AM, Paul McNett <[email protected]> wrote:
> Matt Jarvis wrote:
>> Let me join the fray on this... I prefer SR's version since to me it is
>> much more readable, which I always thought was (one of) the point of
>> XML. Granted yours is much less verbose...
>
> I also prefer SR's version. Readability counts.
>
> Paul
----------------------------------
I prefer Ed's myself but showed the elementary version for ease of
comprehension.
If you look at this code you might see why the XML object is better:
the // is to comment out the line. ;->
/// This will pass the object to the proper loader to generate the
/// SQL Syntax needed for the type of operation
/// 3 diff SPs are called for Insert, Update and Delete
/// </summary>
/// <param name="cmbd">Object to hold all the data from the
Excel sheet</param>
private StringBuilder ImportAppDataToSQL( CMDB cmbd,
StringBuilder swlb)
//string appName,
//string newAppName,
//string action,
//string appId,
//string appDesc,
//string appDetailDesc,
//string bizArea,
//string bizOwner,
//string itArea,
//string itOwner,
//string bizManager,
//string etManager,
here is actual use of the data object cmbd I an taking YES or NO text
and changing to bit 0/1
// update some data types for the backend
cmbd.bVendorRM510 =
cmbd.vendorRM510.ToLower().Equals("yes") ? 1 : 0;
cmbd.bVendorOwned =
cmbd.vendorOwned.ToLower().Equals("yes") ? 1 : 0;
cmbd.drTier1 = cmbd.drTier1.ToLower().Equals("yes")? "1" : "0";
cmbd.bSoxCritical = cmbd.soxCritical.ToLower().Equals("yes")? 1 : 0;
I then passed that object to a SP generator
GenerateSQL.GenSQLString(sql, cmbd);
sql.Replace("*", "");
That method in another class starts out like this:
public static StringBuilder GenSQLString( StringBuilder sql, CMDB cmbd)
{
* -- Like the Case End Case in VFP
switch (cmbd.action.ToUpper())
{
case "UPDATE":
sql.Append("exec CI_ImportExcel @AppName = '" +
HandleSqlQuote(cmbd.appName)
+ "',@newAppName = '" +
HandleSqlQuote(cmbd.newAppName)
+ "',@Action = '" +
HandleSqlQuote(cmbd.action)
+ "',@AppId = '" +
HandleSqlQuote(cmbd.appId)
+ "',@Desc = '" +
HandleSqlQuote(cmbd.appDesc)
+ "',@DetailDesc = '" +
HandleSqlQuote(cmbd.appDetailDesc)
there are over 50 params so I cut it back :)
They passed 50 strings to this builder. I passed one object and one
stringbuilder. That is the power of XML when acting as a CONTAINER
for temporary data. It could not have been a single array because I
have numeric and bool values I have to deal with. The method will
return the stringbuilder where I can do secondary cleaning easily vs
using just a string. That line of code is just below the call to
build the SQL.
--
Stephen Russell
Sr. Production Systems Programmer
First Horizon Bank
Memphis TN
901.246-0159
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.