使用SQL Serverce 2008的vb.net中行/列的数据不存在

时间:2018-12-19 08:03:17

标签: vb.net

   Try
                If conn.State <> ConnectionState.Open Then
                    conn.Open()
                End If
                scmd.CommandText = "select bal, billamnt  from bills "
                Dim drr2 As SqlCeDataReader
                drr2 = scmd.ExecuteReader
                If drr2.Read Then
                    bal = dta(drr("bal"))
                End If
            Catch ex As Exception

            End Try

        Catch ex As Exception

        End Try

我在drr2中遇到错误,错误是:执行drr1时行/列中没有数据

请在vb.net中保存它

1 个答案:

答案 0 :(得分:0)

也许:

        Try
            If conn.State <> ConnectionState.Open Then
                conn.Open()
            End If
            scmd.CommandText = "select bal, billamnt  from bills"
            Dim drr2 As SqlCeDataReader = scmd.ExecuteReader
            While drr2.Read()
                bal = dta(drr2("bal"))
            End While
        Catch ex As Exception

        End Try

如果返回的行多于一列,则需要进行处理。