Hi All,
I have a function call in file1.aspx.cs where I am passing two string values as below.
string strQuery = GlobalQuery.GetQuery(seccondSelection, prefixText);
and inside the GlobalQuery class I have the following code for the static function GetQuery.
public static string GetQuery(string strType, string strLikeChar)
{
strAT = "sample 1";
strMK = "sample 2";
strSN = "sample 3";
string strReturn = string.Empty;
string strDynamic = string.Empty;
strDynamic = "Dynamic";
if ((strLikeChar != "") && (strType != "Aircraft")) strDynamic = strType + "_" + strDynamic;
else strDynamic = strType;
dynamicString = strLikeChar.ToUpper(); //first change
switch (strDynamic)
{
case "Aircraft_Dynamic":
strReturn = "SELECT h.FUNCTION_NO, Eng_Function_API.Get_Description(FUNCTION_NO) Func_desc "
+ " FROM test_table h "
+ "FROM test_table h WHERE h.PRODUCT_NO = '" + strAT + "'"
+ " AND h.MODEL_NO = '" + strMK + "'"
+ " UPPER(Eng_Function_API.Get_Description(FUNCTION_NO)) LIKE '" + dynamicString + "%'"
+ " and h.parent_function_no is null ";
break;
case "Aircraft":
strReturn = "SELECT h.FUNCTION_NO,Eng_Function_API.Get_Description(FUNCTION_NO) Func_desc "
+ "FROM test_table h WHERE h.PRODUCT_NO = '" + strAT + "'"
+ " AND h.MODEL_NO = '" + strMK + "'"
+ " and h.parent_function_no is null ";
break;
// have 2 more case values which will retrieve different set of data.
}
}
Now I want know how to write the query part (highlited in red) in XMlL file and how to replace string values inside the query in XML file(highlited in blue)..
I also want to know how to get that querystring from the XML file
string strQuery = GlobalQuery.GetQuery(seccondSelection, prefixText); // GlobalQuery.GetQuery(seccondSelection, prefixText); should be replaced by the XML file which should contain the query part.
Thanks, Sachi
Loading
VulpesPosted Nov 24, 2011, 2:16 PM
sachi vasishtaPosted Nov 25, 2011, 4:41 AM
sachi vasishtaPosted Nov 24, 2011, 1:33 AM
This is what I have in my XML file(Auto.XML)
this is what I have in my codebehind file
public static string[] DBPopUp(string seccondSelection, string prefixText)
{
string[] arrReturn =null;
string strType = seccondSelection;
string strLikeChar = prefixText;
string strAT = "sample1";
string strMK = "sample2";
string strSN = "sample3";
string strReturn = string.Empty;
string strDynamic = string.Empty;
strDynamic = "Dynamic";
if ((strLikeChar != "") && (strType != "Aircraft")) strDynamic = strType + "_" + strDynamic;
else strDynamic = strType;
dynamicString = strLikeChar.ToUpper();
switch (strDynamic)
{
case "Aircraft_Dynamic":
break;
case "Aircraft": strReturn = // here I want to get the querystring written in the 'command' attribute of the 'aircraft' element of Auto.XML file and I also want to know how to replace @strAT and @strMK parameters
break;
// two more case statements will follow
}
so the querystring returned from the XML should be like this
SELECT h.FUNCTION_NO,IFSAPP.Eng_Function_API.Get_Description(FUNCTION_NO) Func_desc
FROM IFSAPP.PRODUCT_FUNCTION h WHERE h.PRODUCT_NO = 'sample1'(value of @strAT) AND h.MODEL_NO = 'sample2'(value of @strMK) and parent_function_no is null;
strReturn is the final querystring I am going to pass to database.
VulpesPosted Nov 23, 2011, 10:29 AM
sachi vasishtaPosted Nov 23, 2011, 12:44 AM
I want to write the querystring in an existing XML file(Auto.xml).
this is the one I am having
" I want to write the querystring here and also I want to know how to replace the string values(highlited in blue) "
Also please note that the XML file should retrun a querystring of type string.
I mean, in the below code
string strQuery = GlobalQuery.GetQuery(seccondSelection, prefixText);
GlobalQuery.GetQuery(seccondSelection, prefixText); // this returns a querystring, the same I want to achieve using XML(I want to pass those 2 string values to the XML and get the resultant querystring from XML and assign to strQuery).
VulpesPosted Nov 22, 2011, 9:15 AM
In either case, can you give a sample file and indicate under which node etc. the string is to be written.