下面代码运行时出现错误‘找不到可安装的ISAM’Private Sub Command2_Click()
   Dim cn As New ADODB.Connection
   Dim rs As New ADODB.Recordset
   Dim cn1 As New ADODB.Connection
   cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & App.Path & "\Test.xls;ExtendedProperties='Excel8.0;HDR=Yes;IMEX=1'"
   Setrs = cn.Execute("Select StageNo,RhythmNo,NoteNo,DelayTM,NoteTM,NoteNM From[Sheet1$]")
   cn1.Open "Provider=SQLOLEDB.1;Password=123;PersistSecurityInfo=True;UserID=sa;InitialCatalog=Mgame;DataSource=(local)"
   Do While Not rs.EOF
   cn1.Execute ("Insert Into GameData(StageNo,RhythmNo,NoteNo,DelayTM,NoteTM,NoteNM) VALUES('" & Format(rs(0)) & "','" & Format(rs(0)) & "','" & Format(rs(1)) & "','" & Format(rs(2)) & "','" & Format(rs(3)) & "','" & Format(rs(4)) & "','" & Format(rs(5)) & "')")
   rs.MoveNext
   Loop
   rs.Close
   cn.Close
   cn1.Close
   Set rs = Nothing
   Set cn = Nothing
   Set cn1 = Nothing
End Sub

解决方案 »

  1.   

    Setrs = cn.Execute("Select StageNo,RhythmNo,NoteNo,DelayTM,NoteTM,NoteNM From[Sheet1$]")Set rs = cn.Execute("Select StageNo,RhythmNo,NoteNo,DelayTM,NoteTM,NoteNM From[Sheet1$]")
      

  2.   

    把你的工程存盘,然后退VB,打开你工程文件夹,双击工程文件启动VB,运行,然后测试。
      

  3.   

    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & App.Path & "\Test.xls;ExtendedProperties='Excel8.0;HDR=Yes;IMEX=1'"这是没有找到excel文件。
      

  4.   

    你把Microsoft Excel 11.0 Object Library 引用了就好了。我也出现过这个问题。
      

  5.   

    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & App.Path & "\Test.xls;Extended Properties='Excel8.0;HDR=Yes;IMEX=1'"