或者写成这样: Dim r As DataRow = DataTables("财务数据源").SQLFind("[字号] = '" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "' And [凭证号] = '" & e.Form.Controls("dh").text & "' And [安日期生成单号辅助列] = '" & e.Form.Controls("dh1").text & "' And [借或贷] = '借'")
If r IsNot Nothing Then
DataTables("财务数据源").SQLDeleteFor("[字号] = '" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "' And [凭证号] = '" & e.Form.Controls("dh").text & "' And [安日期生成单号辅助列] = '" & e.Form.Controls("dh1").Value & "' And [借或贷] = '借'")
Dim r1s As List(Of DataRow) = DataTables("财务数据源").SQLSelect("[字号] = '" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "' And [凭证号] = '" & e.Form.Controls("dh").text & "' And [安日期生成单号辅助列] = '" & e.Form.Controls("dh1").text & "' And [借或贷] = '贷'",1)
If r1s IsNot Nothing Then
r = DataTables("财务数据源").AddNew
r("_sortkey") = r1s(0)("_sortkey") - 0.0001
End If
Else
r = DataTables("财务数据源").AddNew
End If