我無法在文本框中添加值。每次售票時,我都會將總價格放在一個文本框中,每次爲同一個音樂會銷售一張票時,它會通過將其自身添加到總價中而增加。它在第一次銷售時有效,但在此之後它就崩潰了。這裏是代碼,並提前感謝。無法在結果集索引中找到指定的列索引超出範圍索引超出範圍
Private Function DisplayMoneyTaken() As Integer
Dim totalMoney As Integer
'open the database connection
strSQL = "SELECT MAX(Total_Money) FROM Sales WHERE Concert_Id =" + Mid(cboVenue.Text, 1, 4)
conn.Open()
cmd.Connection = conn
cmd.CommandText = strSQL
cmd.CommandType = CommandType.Text
dr = cmd.ExecuteReader()
'read the record returned
dr.Read()
If IsDBNull(dr.Item(0)) Then
totalMoney = txtPrice.Text
Else
DisplayMoneyTaken = dr.Item("Total_Money") + Val(txtPrice.Text)
End If
'close the database
conn.Close()
Return totalMoney
End Function