1
我是新来的Visual Basic,但我需要遍历数据表中的行,并在测试脚本中使用的值,该脚本如下 -循环通过行动
Public Function TestMain(ByVal args() As Object) As Object
StartApp(URL)
' HTML Browser '
Browser_HtmlBrowser(Document_HomePage(),DEFAULT_FLAGS).Maximize()
Button_AddNewProfilesubmit().Click()
'here is where the rows would be read and the loop would start'
Text_Ctl00MainContentProfileNa().Click(AtPoint(6, 13))
Browser_HtmlBrowser(Document_Http1921685526UserCon(), DEFAULT_FLAGS).InputChars("dataBase_Row_Value")
Table_HtmlTable_1().Click(AtCell(_
AtRow(AtIndex(0)), _
AtColumn(AtIndex(1))))
'here is where the loop would end after all rows had been read'
Return Nothing
End Function
我有一个想法来实现这一点,首先做一个数据库连接,然后创建循环 -
Dim pName As String
Dim datas As DataSet
Dim datar As DataRow
Dim oledat As SqlDataAdapter
oledat = New SqlDataAdapter("SELECT COLUMN FROM DATABASE",ConnectionString)
oledat.Fill(datas)
For Each datar In datas.Tables(0).Rows
pName = datar.Item("PROFILENAME")
Text_Ctl00MainContentProfileNa().Click(AtPoint(6, 13))
Browser_HtmlBrowser(Document_Http1921685526UserCon(), DEFAULT_FLAGS).InputChars(pName)
Table_HtmlTable_1().Click(AtCell(_
AtRow(AtIndex(0)), _
AtColumn(AtIndex(1))))
Next
然而,这是打破,即使有在Visual Studio中没有错误,也仅仅是datas
之前使用的警告它被分配价值。我哪里错了?
当你说这是打破你的意思。运行时会出错吗?如果是的话,错误是什么。 – 2013-03-07 11:13:07
当调试它不运行时,它只是说有构建错误,我用C#编程,如果有错误,它会这样说。我正在使用IBM的理性测试软件来生成脚本。 – Ebikeneser 2013-03-07 11:14:33
那么,构建错误是什么?你说你刚刚有一个警告 - 这不会阻止它编译 – 2013-03-07 11:15:41