本文介绍了我怎么...我得到一个错误“0号位没有行”从这个vb.net代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Imports System.Data.OleDb
Imports System.Data
Public Class WithdrawandDeposit2
    Dim adapt As New OleDbDataAdapter
    Dim dset As New DataSet
    Dim bal, num As String
    Dim total As Integer
    Function draw()
        cn = New OleDb.OleDbConnection
        With cn
            .ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Maccount.accdb"
            .Open()
        End With
        Dim dt As New DataSet("NewAccount")
        'Dim rs As New OleDb.OleDbDataAdapter(" Select Samount from NewAccount where Samount = '" + lblamount.Text + "'", cn)
        Dim rs As New OleDb.OleDbDataAdapter(" Select * from NewAccount where Saccountno = '" + TextBox1.Text + "'", cn)
        rs.Fill(dt)
        If .Tables(dt).rows.count > 0 Then
            bal = dt.Tables(0).Rows(0)(6).ToString()
            num = dt.Tables(0).Rows(0)(0).ToString()
            TextBox2.Text = dt.Tables(0).Rows(0)(2).ToString()
            Return 0
        End If
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Val(WithBox.Text) > bal Then
            LowerBalance.Show()
        ElseIf Me.WithBox.Text = "" Then
            Errorform1.Show()
        Else
            total = bal - Val(WithBox.Text)
            Dim dbcommand As String = "update NewAccount set Samount = '" & total & "'where AccountName='" & TextBox1.Text & "'"
            adapt = New OleDbDataAdapter(dbcommand, cn)
            dset = New DataSet
            adapt.Fill(dset)
            'rs.Dispose()
            'cn.Close()
            Call draw()

        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
        Transactions.Show()
    End Sub

    Private Sub WithdrawandDeposit2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call draw()
        TextBox2.Enabled = False
    End Sub
End Class





我尝试过:



i在bal = dt.tables(0).rows(0)(6)中出错.ToString()



What I have tried:

i am getting an error in bal = dt.tables(0).rows(0)(6).ToString()

推荐答案

If dt.Tables(0).Rows.Count > 0 Then


这篇关于我怎么...我得到一个错误“0号位没有行”从这个vb.net代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 19:43