Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. Imports System.Data
  2. Imports MySql.Data
  3. Imports MySql.Data.MySqlClient
  4.  
  5.  
  6. Module Module1
  7. Public cmd As MySqlCommand
  8.  
  9. Sub main()
  10.  
  11. StartTesting()
  12. End Sub
  13.  
  14. Private Function StartTesting() As Boolean
  15.  
  16.  
  17. Dim value(8) As String
  18. Try
  19. set_database_mysql("127.0.0.1", "DemonstracaoFramework", "root", "YES")
  20. value = select_query("select * from ctinserirloginparaautenticacao where Status = 'Passed' && executed = 'no'")
  21.  
  22.  
  23. Dim Id = value(0)
  24. Dim testId = value(1)
  25. Dim Status = value(2)
  26. Dim result = value(3)
  27. Dim expectedResult = value(4)
  28. Dim login = value(5)
  29. Dim password = value(6)
  30. Dim path = value(7)
  31. Dim versao = value(8)
  32. Dim executed = value(9)
  33.  
  34. Return True
  35. Catch ex As Exception
  36. 'falha
  37. Return False
  38. End Try
  39.  
  40. End Function
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. Public Function select_query(query As String)
  50.  
  51. set_database_mysql("127.0.0.1", "DemonstracaoFramework", "root", "123456za")
  52. cmd.CommandText = query
  53. Dim readerr As MySqlDataReader
  54.  
  55. Try
  56. readerr = cmd.ExecuteReader()
  57. readerr.Read()
  58.  
  59.  
  60.  
  61. Dim value(4) As String
  62. value(0) = reader(readerr, "Id")
  63. value(1) = reader(readerr, "testId")
  64. value(2) = reader(readerr, "Status")
  65. value(3) = reader(readerr, "result")
  66. value(4) = reader(readerr, "expectedResult")
  67. Return value
  68.  
  69.  
  70. Return Nothing
  71. Catch ex As Exception
  72. 'falha
  73.  
  74. Return Nothing
  75. End Try
  76.  
  77.  
  78. End Function
  79.  
  80. '---------------------função reader----------------------
  81. Public Function reader(rea As MySqlDataReader, read As String) As String
  82. If IsDBNull(rea(read)) Then
  83. Return ""
  84. Else
  85. Return rea(read)
  86. End If
  87. End Function
  88.  
  89.  
  90.  
  91.  
  92.  
  93. Public Sub UpdateStatus(query As String)
  94. Try
  95. set_database_mysql("127.0.0.1", "DemonstracaoFramework", "root", "gg1011922467")
  96.  
  97. cmd.CommandText = query
  98. cmd.ExecuteReader()
  99. Catch ex As Exception
  100. 'falha
  101. End Try
  102.  
  103. End Sub
  104.  
  105.  
  106.  
  107.  
  108. Private Sub set_database_mysql(server As String, database As String, user As String, password As String)
  109.  
  110. 'Dim Type()
  111. Dim sql = ""
  112. Dim sqlTable = ""
  113. Dim sql_connect As MySqlConnection
  114. Dim conexaoDataSet As DataSet
  115. Dim cmd As MySqlCommand
  116.  
  117. Try
  118. 'Type = "MySQL"
  119. conexaoDataSet = New DataSet()
  120. sql_connect = New MySqlConnection("Server=" + server + "; Database=" + database + "; Uid=" + user + "; Pwd=" + password)
  121.  
  122. sql_connect.Open()
  123.  
  124. cmd = New MySqlCommand(sql, sql_connect)
  125. Catch ex As Exception
  126. 'falha
  127.  
  128. End Try
  129. End Sub
  130.  
  131. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement