[英]I have stored Table fields and Textbox values in two different list<string> now I want to use those lists in insert query how to do it?
I have stored Table fields and Textbox values in two different list<string>
. 我已经将Table字段和Textbox值存储在两个不同的
list<string>
。
I want to use those lists in insert query how to do it ? 我想在插入查询中使用这些列表怎么做? and what about quotation marks if value is numeric ?
如果值是数字,引号又如何呢?
foreach (Control Txt_Name in TB_List) {
String TxtName = Txt_Name.Text;
String field_name = Txt_Name.Name.Substring(3);
Field_Name.Add(field_name);
TB_Name.Add(TxtName);
}
SqlCommand cmd = new SqlCommand("Insert into "+ Table_Name +
"('"+ Field_Name + "') Values('" + TB_Name + "')", con);
Table field must be separated with commas. 表字段必须用逗号分隔。 Value field must be treated in different ways.
值字段必须以不同的方式处理。 Example: String values want the single quote before and after the value, int doesn't.. The best way is to handle the insert statement with a sql procedure.
示例:字符串值希望在值的前后使用单引号,而int则不希望。最好的方法是使用sql过程来处理insert语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.