asp.netr把excel导入sql数据库的自定义类
以下是引用片段: public class savetosql { public string strnewcodeid = string.empty; public string strnewcode = string.empty; public string strnewdes = string.empty; public string stroldcodeid = string.empty; public string stroldcode = string.empty; public string strolddes = string.empty; public string server = string.empty; public string database = string.empty; public string uid = string.empty; public string pwd = string.empty ; private string tablename = string.empty; /// <summary> /// 目的表的名称 /// </summary> public string tablenames { get{return tablename;} set{tablename=value;} } public savetosql() { } /// <summary> /// 保存数据 /// </summary> public void save() { string strconpath = string.format("server={0};database={1};uid={2};pwd={3}",this.server,this.database,this.uid,this.pwd); sqlconnection con1 = new sqlconnection(strconpath); con1.open(); sqlcommand com1 = new sqlcommand(); com1.commandtext = "insert into "+tablename+"(newcodeid,newcode,newdes,oldcodeid,oldcode,olddes) values(’"+strnewcodeid+"’,’"+strnewcode+"’,’"+strnewdes+"’,’"+stroldcodeid+"’,’"+stroldcode+"’,’"+strolddes+"’)"; com1.connection=con1; com1.executenonquery(); con1.dispose(); } } |
商业源码热门下载www.html.org.cn
新闻热点
疑难解答
图片精选