当我尝试在btnSave上插入七个值时,它会插入六个,如果六个,则插入五个在给定代码中会出现什么问题? [英] When I trying to insert seven values on btnSave it inserts six , if Six it insert Five What will be the issue in the given Code?
本文介绍了当我尝试在btnSave上插入七个值时,它会插入六个,如果六个,则插入五个在给定代码中会出现什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Try
'SetRowData()
Dim table As DataTable = TryCast(ViewState("CurrentTable"), DataTable)
If table IsNot Nothing Then
For Each row As DataRow In table.Rows
Dim funob As String = TryCast(row.ItemArray(1), String)
Dim measur As String = TryCast(row.ItemArray(2), String)
Dim d_line As String = TryCast(row.ItemArray(3), String)
Dim wtfact As String = TryCast(row.ItemArray(4), String)
If funob IsNot Nothing OrElse measur IsNot Nothing OrElse d_line IsNot Nothing OrElse wtfact IsNot Nothing Then 'OrElse drpQual IsNot Nothing
'' str contains Insert query
cmd.CommandText = str
cmd = New SqlCommand(str, con)
cmd.ExecuteNonQuery()
con.Close()
End If
Next
lblusrmsg.Visible = True
End If
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
和ViewState(CurrentTable)包含来自网格的值。
我使用断点进行代码调试。
and in the ViewState("CurrentTable") contain the values from grid.
I did Code debug using breakpoint.
推荐答案
试试这个,
Try this,
Try
'SetRowData()
Dim table As DataTable = TryCast(ViewState("CurrentTable"), DataTable)
If table IsNot Nothing Then
For Each row As DataRow In table.Rows
Dim funob As String = TryCast(row.ItemArray(0), String)
Dim measur As String = TryCast(row.ItemArray(1), String)
Dim d_line As String = TryCast(row.ItemArray(2), String)
Dim wtfact As String = TryCast(row.ItemArray(3), String)
Dim wtfact As String = TryCast(row.ItemArray(5), String)
If funob IsNot Nothing OrElse measur IsNot Nothing OrElse d_line IsNot Nothing OrElse wtfact IsNot Nothing Then 'OrElse drpQual IsNot Nothing
'' str contains Insert query
cmd.CommandText = str
cmd = New SqlCommand(str, con)
cmd.ExecuteNonQuery()
con.Close()
End If
Next
lblusrmsg.Visible = True
End If
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
这篇关于当我尝试在btnSave上插入七个值时,它会插入六个,如果六个,则插入五个在给定代码中会出现什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文