'*************************************** ****************************************
'Objective: To perform Excel operations
'Input parameters:
'Return result:
'Considerations:
By Chen nengtech (http://itestware.com)
'Date:
'*************************************** ****************************************
Testadoexcel
Sub testadoexcel
'Create ado
Set conn = Createobject ("ADODB. Connection ")
'Open link
Conn. Open "provider = Microsoft. Jet. oledb.4.0; Data Source = D:/cnj/qnap automated test project/mytest/adoexcel/data/adoexcel.xls; extended properties = Excel 8.0"
'Query
SQL = "select * from [adoexcel $]"
Set recset = conn. Execute (SQL)
Recset. movefirst
While not recset. EOF
Msgbox recset. Fields ("username"). Value & "," & recset. Fields ("password"). Value
Recset. movenext
Wend
'Insert
SQL = "insert into [adoexcel $] values ('aaa', 'bbb ')"
Conn. Execute (SQL)
'Update
SQL = "Update [adoexcel $] Set [Password] = 'Hello world' where [username] = 'allen '"
Conn. Execute (SQL)
'Close the link
Conn. Close
End sub