row(0)是啥意思

kingzhh 2008-05-07 02:21:48
duwamish7中的代码,business/rules/customer.vb,这是新增记录的代码,当中有句理解不来With customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows(0),rows(0)是啥意思?(代码下,红色部分)

Public Function Insert (ByVal customer as CustomerData) As Boolean
'
' Check Preconditions
'
ApplicationAssert.CheckCondition(Not customer Is Nothing,"customer Parameter cannot be null",ApplicationAssert.LineNumber)
ApplicationAssert.CheckCondition(customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows.Count = 1,"customer Parameter can only contain 1 row",ApplicationAssert.LineNumber)

Dim tmpCustomer As CustomerData 'used to see if the customer already exists
Dim result as Boolean

With customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows(0)
'
' Do core validation
'
result = Validate (customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows(0))
'
' Do additional validation
'
If Len(.GetColumnError (CustomerData.EMAIL_FIELD)) < 1 Then
'
' Email address passed format verification, now ensure that it
' does not already exist in the database.
'
tmpCustomer = GetCustomerByEmail(CStr(.Item(CustomerData.EMAIL_FIELD)))
If tmpCustomer Is Nothing Then
'email is unique, Save off the new customer
If result Then
With New Customers
result = .InsertCustomer(customer)
End With
End If
Else
'
' Email is not unique, flag the error
'
.SetColumnError(CustomerData.EMAIL_FIELD, CustomerData.EMAIL_FIELD_NOT_UNIQUE) 'email field is not unique
.RowError = CustomerData.INVALID_FIELDS
result = false
End If
End If
End With
'
' Return the result of the operation
'
Insert = result
End Function
...全文
962 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zll711 2008-05-07
  • 打赏
  • 举报
回复
上面不是写的很清楚吗,customer Parameter can only contain 1 row,
仅仅一行,所以就row(0)了
kingzhh 2008-05-07
  • 打赏
  • 举报
回复
可能意思表达不清,我的意思是,这段代码的作用是新增记录时的数据验证,为什么会用.row(0),然道.row(0)代表的是新增的记录?
HimeTale 2008-05-07
  • 打赏
  • 举报
回复
既然当了程序员,查数就要从0开始
vlsm 2008-05-07
  • 打赏
  • 举报
回复
第一行
华芸智森 2008-05-07
  • 打赏
  • 举报
回复
CustomerData 是自定义的一个类或继承DATASET的一个类吧.Rows(0) 指里面TABLE的第零行.

kakajya 2008-05-07
  • 打赏
  • 举报
回复
第一行

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧