从列表中提取数据 [英] extract data from a list
本文介绍了从列表中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我为wcf服务发送了一个数据列表(类员工的类型),其中包括一个int,string,string.
我想将这些值发送到sql数据库,所以如何从列表中提取这些值并将其发送到db
谢谢
p.s um a newb:D
hey guys um sending a data list(type of class employee) for a wcf service which includes an int , string ,string .
i want to send that values to a sql database , so how can i extract those values from the list and send it to the db
thanks
p.s um a newb :D
推荐答案
嘿,
nvm我自己想到了
我的代码是
hey ,
nvm i figured it on my own
my code is
foreach (var sqllist in list)
{
emp2.id = sqllist.id;
emp2.fname = sqllist.fname;
emp2.sname = sqllist.sname;
string qry = string.Format("INSERT INTO test_tbl(id, fname, sname) VALUES('" + @emp2.id +"','"+@emp2.fname+"','"+@emp2.sname+ "')");
SqlCommand com = new SqlCommand(qry, con);
com.ExecuteNonQuery();
}
这篇关于从列表中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文