问题描述
这是迪纳卡.我正在输入xml,其中包含表名,列名,类型和值.我希望通用函数通过使用上述xml表值来插入一条记录.
请帮帮我.....
This is dinakar. I am having input xml, which contain table name,column name ,type and values. I want generic function to insert a record by using above xml table values.
please help me out please.....
推荐答案
- 从XML中提取表名和列名,值和类型.实现此目标的一种方法是使用XPath表达式.
- 根据在步骤1中检索到的数据构造插入语句.
- Extract the table name and column name(s), value(s) and type(s) from your XML. One way to achieve that would be the use of XPath expressions.
- Construct insert statements from the data retrieved in step 1.:
String myStringSQLStatement = String.Format("INSERT INTO {0} {1} VALUES({3})", tableName, columnList, paramNameList);
其中,tableName
是XML中的表名,而columnList
是用逗号分隔的列名列表.对于paramNameList
,请使用以@开头的列名,并以逗号分隔.
where tableName
is the table name from the XML and the columnList
is the list of the column names seperated by a comma. For the paramNameList
use the column names prefixed by a @ and also separate them by a comma.
遵循此路线,使您的问题与进度保持最新,并告诉我们在解决此问题时是否遇到任何问题.
最好的问候,
--MRB
Follow this route, keep your question updated with your progress and tell us if you run across any problems while you''re working this out.
Best Regards,
--MRB
这篇关于插入记录的通用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!