读者跳过记录 [英] Reader skipping records
本文介绍了读者跳过记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个程序,该程序将向用户发送电子邮件通知,该用户将获得报销索赔。现在,我注意到我的电子邮件发送不等于正在上传的数据。
我认为读者正在跳过记录。读者如何不跳过记录。在此先感谢
我尝试过:
I created a program which will send email notification to the user who will be credited the reimbursement claims. Now, I have notice that my email send is not equal to the data being uploading.
I think reader is skipping records. How do reader will not skip records. Thanks in advance
What I have tried:
Dim myreader As OleDb.OleDbDataReader
myreader = sqlcmd.ExecuteReader()
myreader.Read()
Dim i As Integer = 0
Dim myArray As New ArrayList
myArray.Add(myreader.Item("vendor_name"))
Do While myreader.Read <> False
Dim x As Integer, y As Boolean
Dim vDetail As String
Dim vID As String
Dim vDesc As String
Dim vName As String = myreader.Item("vendor_name").ToString
Dim vEmail As String = myreader.Item("email_address").ToString
txtmsg.Text = "Processing: " & vName & "'s Payroll..."
txtmsg.Refresh()
vDetail = ""
vID = ""
vID = myreader.Item("vendor_id").ToString
irec = myArray.Add(myreader.Item("vendor_name"))
retry:
vDetail = vDetail & vbCrLf
vDetail = vDetail & "Invoice No.: " & myreader.Item("invoice_num").ToString
vDetail = vDetail & " Amount: " & Format(myreader.Item("amount").ToString, "Standard")
vDetail = vDetail & vbCrLf
vDesc = myreader.Item("Description").ToString
y = False
For x = 1 To Len(vDesc)
If x Mod 70 = 0 Then
y = True
End If
If Mid(vDesc, x, 1) = " " And y Then
y = False
If x < Len(vDesc) Then
vDesc = Mid(vDesc, 1, x - 1) & vbCrLf & Mid(vDesc, x + 1)
End If
End If
Next
vDetail = vDetail & vDesc
i = i + 1
If myreader.Read <> False Then
If myreader.Item("vendor_id") = vID Then
GoTo retry
End If
End If
i = i - 1
With ProgressBar
.Value = 100
.Refresh()
End With
If vEmail <> "" Then SendMail(vEmail, vName, vDetail)
'Move To Next
i = i + 1
Loop
End If
推荐答案
读者不会跳过记录。在调试器中运行代码会告诉你。
你额外的.Read调用导致问题的可能性要高得多。你应该只在你的循环中有一个.Read调用,但你有多个,特别是在if
语句中。
你猜你的代码在做什么,即跳过记录。这是一个巨大的信号,你应该在调试器下运行它,这样你就可以完全按照代码所做的操作并检查变量内容。
另外,如果你正在使用一个Goto语句,你真的需要检查你正在使用的逻辑。
了解调试器。它是调试你和你对代码的理解。
The reader is not skipping records. Running the code in the debugger would tell you that.
Chances are far higher that your extra .Read calls are causing the problem. You should only ever have a single .Read call in your loop, but you've got more than one, specifically in thatif
statement.
You're guessing at what you're code is doing, i.e. "skipping records". That's a huge sign you should be running this under the debugger so you can follow exactly what the code is doing and examine variable contents.
Also, if you're using a Goto statement, you really need to examine the logic you're using.
Get to know the debugger. It's there to debug YOU and your understanding of the code.
这篇关于读者跳过记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文