if (!string.IsNullOrEmpty(strList[i]) && strList[i].IndexOf("=", 0, 1) > -1)
{
sAppendNodeText += strList[i - 1] + ",";
}
}
if (sAppendNodeText.Length > 1)
{
sAppendNodeText = sAppendNodeText.Substring(0, sAppendNodeText.Length - 1);
}
sAppendNodeText = "UPDATE【" + sAppendNodeText + "】";
break;
}
case "DELETE":
{
strList = sOperationSQL.Trim().Split(new char[2] { ' ', ',' });
for (int i = 0; i < strList.Length; i++)
{
if (!string.IsNullOrEmpty(strList[i]) && strList[i].IndexOf("=") > -1 && strList[i].Length > 1)
{
int iIndex = strList[i].IndexOf("=");
if (iIndex > 0)
{
sAppendNodeText += strList[i].Substring(0, iIndex) + ",";
}
}
if (!string.IsNullOrEmpty(strList[i]) && strList[i].IndexOf("=", 0, 1) > -1)
{
sAppendNodeText += strList[i - 1] + ",";
}
}
if (sAppendNodeText.Length > 1)
{
sAppendNodeText = sAppendNodeText.Substring(0, sAppendNodeText.Length - 1);
}
sAppendNodeText = "DELETE【" + sAppendNodeText + "】";
break;
}
}
return sAppendNodeText;
}
测试用例:
string sSelSQL = "SELECT BSM FROM STUDENT";
string sResult = GetSQLOperateField(sSelSQL);
this.treeList1.AppendNode(new object[] { sResult }, null);
string sUpdata = "UPDATE STUDENT SET";
sResult = GetSQLOperateField(sUpdata);
this.treeList1.AppendNode(new object[] { sResult }, null);
string sInsertSQL = "INSERT INTO STUDENT,ID='2001' WHERE SCORE='95'";
//string sInsertSQL = "INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')"; //暂不支持这种写法
sResult = GetSQLOperateField(sInsertSQL);
this.treeList1.AppendNode(new object[] { sResult }, null);
很简单,有待完善。
在C语言中解析JSON配置文件