07-16-2008, 09:01 PM
I am having trouble with oracle database connection, how should I know my connection is success or not. When I run the script it is giving 0 failed result, any sample code is very helpful. Please check the below sample code
Code:
Dim OdbcDSN
Dim connect, sql, resultSet
Dim dbConn
Dim rsGetAccountData
Dim strSQL, strCategory, strCategoryType
Dim a1
On Error Resume Next
Public Sub SetDBConnection
'Purpose: Set the database connection
Set dbConn = CreateObject("ADODB.Connection")
dbConn.ConnectionString = "DSN=sys_qtp_ora;Server=test;Uid=username;Pwd=password;"
dbConn.Open
End Sub
Public Sub GetAccountData()
Set resultSet = CreateObject ("ADODB.RecordSet")
'Purpose: Get the account data information from table
strSQL = "select first_name,last_name from names where rownum <10"
' strSQL = "insert into aaa values(1234)"
resultSet = dbConn.Execute(strSQL)
'MsgBox "Hello everyone!"
MsgBox "Not Connected" & resultSet
Do While Not resultSet.eof
If a1 = 10 then
MsgBox "reddy" & resultSet("first_name")
end if
resultSet.MoveNext
Loop
resultSet.Close
End Sub
Call SetDatabase()
Call GetAccountData()