如何用vb将excel表中的数据存入SQL Server数据库中,请各位高人不吝赐教。

解决方案 »

  1.   

    调用execel 对象,使用其中方法,属性,读取工作簿里表单的cell对象,再存入数据库
      

  2.   

    这个是用vb访问excel的,
    http://www.sijiqing.com/vbgood/experience/index.asp?action=read&id=2581
    至于存入sql,用ado就可以实现啊!
    http://www.sijiqing.com/vbgood/experience/index.asp?action=read&id=3347
      

  3.   

    把Excel表单当作数据表使用,表单列头即为数据表字段列
    简单例子adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & dirname & filename & ".xls" & ";Extended Properties='Excel 8.0;HDR=Yes'"
        adoRecordset.Open "select * from [share_tow.sheet$] where 编号 is not null", adoConnection, adOpenKeyset, adLockOptimistic
        If Not adoRecordset.EOF And Not adoRecordset.BOF Then
            Do While Not adoRecordset.EOF
                ’取得记录的值,插入SQL Server
                adoRecordset.MoveNext
            Loop
            adoRecordset.Close
        end if
        If adoRecordset.State = 1 Then
            adoRecordset.Close
        End If
        adoConnection.Close