找回密码
 立即注册

QQ登录

只需一步,快速开始

jplzj
论坛元老   /  发表于:2010-12-2 12:53  /   查看:9145  /  回复:3
Private Sub BtISave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtISave.Click
     
                    For j As Integer = 2 To FpSpread2.Sheets(0).RowCount - 1
                       
                            Try
                   ADDDAML("INSERT INTO XX (DL,XH,MC,N,Y,R,FS,YS,BS,BM,BZ)  VALUES ('" & FpSpread2.Sheets(0).Cells(j - 1, 1).Tag.ToString & "','" & FpSpread2.Sheets(0).Cells(j, 0).Text & "','" & FpSpread2.Sheets(0).Cells(j, 1).Text & "','" & FpSpread2.Sheets(0).Cells(j, 2).Text & "','" & FpSpread2.Sheets(0).Cells(j, 3).Text & "','" & FpSpread2.Sheets(0).Cells(j, 4).Text & "','" & FpSpread2.Sheets(0).Cells(j, 5).Text & "','" & FpSpread2.Sheets(0).Cells(j, 6).Text & "','" & H & "','" & LbXM.Tag.ToString & "','" & FpSpread2.Sheets(0).Cells(j, 7).Text & "')", 0) Then
                         Catch ex As Exception
                             
                            End Try
代码如上,这是一个数据库插入数据代码,偶尔会出现invalid row index :**寻思半天也没发现有什么问题,请高手看看有什么问题?

3 个回复

倒序浏览
gw0506
超级版主   /  发表于:2010-12-2 13:46:00
沙发
肯定是某一个变量越界了。
你可以下断点跟一下~
回复 使用道具 举报
jplzj
论坛元老   /  发表于:2010-12-2 14:56:00
板凳
好的,我试试,
奇怪的是,这个错误只是偶然出现
回复 使用道具 举报
gw0506
超级版主   /  发表于:2010-12-2 15:09:00
地板
恩,这样的问题比较难处理~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部