我有以下代码:
Do Until i = dsSalesRep.Tables(0).Rows.Count
strRepID = dsSalesRep.Tables(0).Rows(i)("repID").ToString
strLBP = dsSalesRep.Tables(0).Rows(i)("officename").ToString
strLBPEmail = dsSalesRep.Tables(0).Rows(i)("cemail").ToString
strCCRepEmail = dsSalesRep.Tables(0).Rows(i)("cc1").ToString
strRepName = dsSalesRep.Tables(0).Rows(i)("firstname").ToString & " " & dsSalesRep.Tables(0).Rows(i)("lastname").ToString
strRepEmail = dsSalesRep.Tables(0).Rows(i)("email").ToString
strRepPhone = dsSalesRep.Tables(0).Rows(i)("phone").ToString
searchStr3 = "SELECT * FROM LookupSalesRep WHERE repID='" & strRepID & "'"
Dim SqlAdapter3 As New SqlDataAdapter(searchStr3, myConn2)
Dim dsTerritories As New DataSet
myConn2.Open()
SqlAdapter3.Fill(dsTerritories)
strCountry = dsTerritories.Tables(0).Rows(0)("country").ToString
'strCountry = dsTerritories.Tables(0).Rows.Count.ToString
但是,当我运行网页时,它给了我错误:位置 0 处没有行。
但是当我使用代码时
strCountry = dsTerritories.Tables(0).Rows.Count.ToString
strCountry 获得正确的行数。请帮忙 :(