|
@@ -995,7 +995,6 @@ |
995 |
995 |
|
{ |
996 |
996 |
|
RaiseErrorEvent("(error) parsing date value in AddCommandParam string version:"+pValue); |
997 |
997 |
|
return false; |
998 |
|
- |
break; |
999 |
998 |
|
} |
1000 |
999 |
|
strTemp = String.Format("{0:yyyy-MM-dd hh:mm:ss}", myDate); |
1001 |
1000 |
|
|
|
@@ -1607,6 +1606,38 @@ |
1607 |
1606 |
|
|
1608 |
1607 |
|
#region Data Fetch Functions |
1609 |
1608 |
|
|
|
1609 |
+ |
//shared helper method for adding parameters of various types passed for parameterized query |
|
1610 |
+ |
//constructions |
|
1611 |
+ |
private void AddParameters(IfxCommand pCommand, params object[] pParams) |
|
1612 |
+ |
{ |
|
1613 |
+ |
if (pParams != null) |
|
1614 |
+ |
{ |
|
1615 |
+ |
//parameters are positional, not named - just tack them on with no name here, the type is determined on the fly. |
|
1616 |
+ |
foreach (object oParam in pParams) |
|
1617 |
+ |
{ |
|
1618 |
+ |
IfxParameter dbparam = new IfxParameter(); |
|
1619 |
+ |
|
|
1620 |
+ |
if (oParam is IfxParameter) |
|
1621 |
+ |
{ |
|
1622 |
+ |
pCommand.Parameters.Add(oParam); |
|
1623 |
+ |
} |
|
1624 |
+ |
else if (oParam is string) |
|
1625 |
+ |
{ |
|
1626 |
+ |
dbparam.IfxType = IfxType.NVarChar; |
|
1627 |
+ |
dbparam.Value = oParam; |
|
1628 |
+ |
pCommand.Parameters.Add(dbparam); |
|
1629 |
+ |
} |
|
1630 |
+ |
else if (oParam is bool | oParam is int | oParam is short | oParam is long) |
|
1631 |
+ |
{ |
|
1632 |
+ |
pCommand.Parameters.Add("", oParam); |
|
1633 |
+ |
} |
|
1634 |
+ |
else |
|
1635 |
+ |
{ |
|
1636 |
+ |
pCommand.Parameters.Add("", oParam.ToString()); |
|
1637 |
+ |
} |
|
1638 |
+ |
} |
|
1639 |
+ |
} |
|
1640 |
+ |
} |
1610 |
1641 |
|
|
1611 |
1642 |
|
/// <summary> |
1612 |
1643 |
|
/// Allows you to fetch a single value from a table or view. All values are returned as strings |
|
@@ -1661,14 +1692,7 @@ |
1661 |
1692 |
|
oCommand.Connection = _iFxConnection; |
1662 |
1693 |
|
oCommand.CommandText = pQueryString; |
1663 |
1694 |
|
|
1664 |
|
- |
//in ODBC the params are not passed in by name but are positional - just toss each value in - it's type will be determined |
1665 |
|
- |
//on the fly - hence the parameters list being pass in as an array of objects. |
1666 |
|
- |
foreach (object oParam in pParams) |
1667 |
|
- |
{ |
1668 |
|
- |
IfxParameter oNewParam = new IfxParameter("",IfxType.NVarChar); |
1669 |
|
- |
oNewParam.Value = oParam; |
1670 |
|
- |
oCommand.Parameters.Add(oNewParam); |
1671 |
|
- |
} |
|
1695 |
+ |
AddParameters(oCommand, pParams); |
1672 |
1696 |
|
|
1673 |
1697 |
|
//execute the query |
1674 |
1698 |
|
try |
|
@@ -1863,13 +1887,7 @@ |
1863 |
1887 |
|
_command.Connection = _iFxConnection; |
1864 |
1888 |
|
_command.CommandText = pCountQueryString; |
1865 |
1889 |
|
|
1866 |
|
- |
//parameters in ODBC are positional, not named - just stack them in as they are passed in. |
1867 |
|
- |
foreach (object oParam in pParams) |
1868 |
|
- |
{ |
1869 |
|
- |
IfxParameter oNewParam = new IfxParameter("", IfxType.NVarChar); |
1870 |
|
- |
oNewParam.Value = oParam; |
1871 |
|
- |
_command.Parameters.Add(oNewParam); |
1872 |
|
- |
} |
|
1890 |
+ |
AddParameters(_command, pParams); |
1873 |
1891 |
|
|
1874 |
1892 |
|
try |
1875 |
1893 |
|
{ |
|
@@ -1939,13 +1957,7 @@ |
1939 |
1957 |
|
_command.Connection = _iFxConnection; |
1940 |
1958 |
|
_command.CommandText = pQueryString; |
1941 |
1959 |
|
|
1942 |
|
- |
//parameters in ODBC are positional, not named - just stack them in as they are passed in. |
1943 |
|
- |
foreach (object oParam in pParams) |
1944 |
|
- |
{ |
1945 |
|
- |
IfxParameter oNewParam = new IfxParameter("", IfxType.NVarChar); |
1946 |
|
- |
oNewParam.Value = oParam; |
1947 |
|
- |
_command.Parameters.Add(oNewParam); |
1948 |
|
- |
} |
|
1960 |
+ |
AddParameters(_command, pParams); |
1949 |
1961 |
|
|
1950 |
1962 |
|
try |
1951 |
1963 |
|
{ |
|
@@ -2562,21 +2574,8 @@ |
2562 |
2574 |
|
_command.Connection = _iFxConnection; |
2563 |
2575 |
|
_command.CommandText = pQueryString; |
2564 |
2576 |
|
|
2565 |
|
- |
//parameterized queries in .net driver seems to be unreliable at this point - running into some issues with UTF8 strings and there is no |
2566 |
|
- |
//add with value type construction in other .net db drivers - need to investigate this further. |
2567 |
|
- |
foreach (object oParam in pParams) |
2568 |
|
- |
{ |
2569 |
|
- |
if (oParam is IfxParameter) |
2570 |
|
- |
{ |
2571 |
|
- |
_command.Parameters.Add(oParam); |
2572 |
|
- |
} |
2573 |
|
- |
else |
2574 |
|
- |
{ |
2575 |
|
- |
IfxParameter oNewParam = new IfxParameter("", IfxType.NVarChar); |
2576 |
|
- |
oNewParam.Value = oParam; |
2577 |
|
- |
_command.Parameters.Add(oNewParam); |
2578 |
|
- |
} |
2579 |
|
- |
} |
|
2577 |
+ |
AddParameters(_command, pParams); |
|
2578 |
+ |
|
2580 |
2579 |
|
try |
2581 |
2580 |
|
{ |
2582 |
2581 |
|
pDataReader = _command.ExecuteReader(); |
|
@@ -2675,25 +2674,7 @@ |
2675 |
2674 |
|
//which is acceptable. Connection allows for 10 by default. |
2676 |
2675 |
|
using (IfxCommand oCommand = new IfxCommand(pQueryString, _iFxConnection)) |
2677 |
2676 |
|
{ |
2678 |
|
- |
if (pParams != null) |
2679 |
|
- |
{ |
2680 |
|
- |
//parameters are positional, not named - just tack them on with no name here, the type is determined on the fly. |
2681 |
|
- |
foreach (object oParam in pParams) |
2682 |
|
- |
{ |
2683 |
|
- |
IfxParameter dbparam = new IfxParameter(); |
2684 |
|
- |
|
2685 |
|
- |
if (oParam is string) |
2686 |
|
- |
{ |
2687 |
|
- |
dbparam.IfxType = IfxType.NVarChar; |
2688 |
|
- |
dbparam.Value = oParam; |
2689 |
|
- |
oCommand.Parameters.Add(dbparam); |
2690 |
|
- |
} |
2691 |
|
- |
else |
2692 |
|
- |
{ |
2693 |
|
- |
oCommand.Parameters.Add("", oParam.ToString()); |
2694 |
|
- |
} |
2695 |
|
- |
} |
2696 |
|
- |
} |
|
2677 |
+ |
AddParameters(oCommand, pParams); |
2697 |
2678 |
|
|
2698 |
2679 |
|
using (IfxDataAdapter oDataAdapter = new IfxDataAdapter(oCommand)) |
2699 |
2680 |
|
{ |