调用webservice导excel文件内容进入数据库

本文介绍了如何使用VB.NET调用WebService将Excel数据导入数据库,包括创建数据库存储过程、处理数据类型冲突及连接字符串设置。在导入过程中遇到数据丢失和科学计数法显示的问题,通过调整HDR和IMEX属性解决了问题。
摘要由CSDN通过智能技术生成

一个早期vb.net写的程序,需要增加功能,要导入excel数据,并按条件显示。

1.数据库端
1.1因为是要把表作为存储过程的输入参数,所以先新建一个数据类型xtabletype
  create type xtabletype as table(prodid varchar(20),itemid  varchar(20),target  varchar(150))
1.2新建存储数据的表
  create table import_excel_target
(prodid varchar(200),itemid varchar(20),target varchar(200),id int identity(1,1))
1.3新建存储过程 
create procedure import_excel(@tb xtabletype readonly)
as
truncate table import_excel_target
insert into import_excel_target (prodid,itemid,target) select prodid,itemid,target from @tb

2.服务器端
在webservice.axsm文件中添加了一个方法:
 <WebMethod()>
    Public Function import_excel(dt As DataTable) As String
        Dim result As String
        Dim parms As New Dictionary(Of String, Object) From { {"@tb", dt}}
        If dt.Rows.Count > 0 Then
            dt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值