急急急!!! 如何将订单导入到OA中啊?
解决方案 »
- 请教正则表达
- 一个正则问题
- 怎样使用guid生成一串12位的数字,急,在线===========================================
- 求教各位大侠,OpenFileDialog组件,可以在web程序中使用吗?
- 请教 C#用OLEDB如何连接postgre
- 高手帮帮我,我都快被折磨疯了....
- DataSet不回收会出现什么情况
- 有谁能帮我出几条.NET的考题呀!
- ----------------各位大侠,我的电脑中毒了,是一种w32.Pinfi的病毒,请问各位大侠用什么工具才可以
- sender 传过去的是什么?以及DataBinding的一些
- 如何使用SqlParamenter向表中的字段插入Null值?
- 怎么取出GridView列的值
{
ProductService.productAllDelete();
string mystring = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" +Server.MapPath("upexcel/uplexcl.xls") + "; Extended Properties=\"Excel 8.0; HDR=No; IMEX=1;\"";
OleDbConnection cnnxls = new OleDbConnection(mystring);
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [0.3-FJ-VS-VVS$]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
DataTable table=myDs.Tables[0];
foreach(DataRow row in table.Rows){
这里面写插入数据库的方法
}
}
catch (Exception)
{
Response.Write("<script>alert('导入Excel失败 请确保您上传的excel的编码格式是正确的!')</script>");
}
Response.Write("<script>alert('导入Excel成功!')</script>");这个是 excel 导入数据库的代码
如果不是excel的又该怎样操作啊?
如果不是excel 那是什么文件呢? 不同的文件操作不同啊 你又没说是什么文件 我怎么说啊
{
ProductService.productAllDelete();
string mystring = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" +Server.MapPath("upexcel/uplexcl.xls") + "; Extended Properties=\"Excel 8.0; HDR=No; IMEX=1;\"";
OleDbConnection cnnxls = new OleDbConnection(mystring);
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [0.3-FJ-VS-VVS$]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
DataTable table=myDs.Tables[0];
foreach(DataRow row in table.Rows){
if (row[3].ToString() == "形状")
{
continue;
}
if (row[3].ToString()=="")
{
break;
}
Product pd = new Product();
pd.Product_bianhao1 = row[0].ToString();
pd.Product_didian = row[1].ToString();
pd.Product_bianhao2 = row[2].ToString();
pd.Product_shape=row[3].ToString();
double sumMoney= double.Parse( row[4].ToString());
string dos = sumMoney.ToString("F3");
pd.Product_Weight = dos; pd.Product_color = row[5].ToString();
pd.Product_Clarity = row[6].ToString();
pd.Product_Cut = row[7].ToString();
pd.Product_Polishing = row[8].ToString();
pd.Product_duic=row[9].ToString();
ProductService.productAdd(pd);
}
}
catch (Exception)
{
Response.Write("<script>alert('导入Excel失败 请确保您上传的excel的编码格式是正确的!')</script>");
}
Response.Write("<script>alert('导入Excel成功!')</script>");
上面是插入产品的列子