rodolfo_panganiban

Mysql in visual basic Sample Source Code

This item was filled under [ FREE SOURCE CODE, Visual Basic 6.0 ]


  1. 'Here I create a variable named MySQL as a new connection object for MySQL
  2. Global MySQL As New MySQL_CONNECTION
  3.  
  4. Private Function MySQL_Connect() As Boolean
  5. Dim res_MySQL As MYSQL_CONNECTION_STATE
  6.  
  7. MySQL_Connect = False
  8. res_MySQL = MySQL.OpenConnection("server", "username", "password", "database", 3306, CLIENT_COMPRESS)
  9.  
  10. If res_MySQL = MY_CONN_OPEN Then
  11. MySQL_Connect = True
  12. End Function
  13.  
  14. ' Query -> MySQL query to execute.
  15. ' CloseRS -> Optional. Close recordset created after executing Query.
  16. ' RS -> Optional. Reference to externaly created variable, declared as MYSQL_RS. If not closed, it will be available to the program after the query is executed.
  17. ' lAffected -> Optional. Numer of rows affected after te Query.
  18. Public Sub SQLQuery(ByVal Query As String, Optional ByVal CloseRS As Boolean = False, Optional ByRef RS As MYSQL_RS, Optional ByRef lAffected As Long)
  19. Dim ERR As MYSQL_ERR
  20.  
  21. Set RS = MySQL.Execute(Query, lAffected)
  22. Set ERR = MySQL.Error
  23.  
  24. If ERR.Number <> 0 Then
  25. ' Handle any eventual errors that occurred during MySQL query
  26. End If
  27. ERR.Clear
  28. Set ERR = Nothing
  29.  
  30. If CloseRS Then
  31. RS.CloseRecordset
  32. Set RS = Nothing
  33. End If
  34. End Sub
  35.  
  36. Public Sub DisplayData(ByRef RS As MYSQL_RS)
  37. Dim p_Date As Date
  38. If RS.RecordCount > 0 Then
  39. p_Date = FromUnixTime(RS.Fields("date").value)
  40. lblDate.Caption = Format(p_Date, "dd. mmmm yyyy")
  41. txtTitle.Text = UTF8.UTF8ToANSI(RS.Fields("title").value)
  42. txtDescription.Text = UTF8.UTF8ToANSI(RS.Fields("describe").value)
  43. txtContent.Text = UTF8.UTF8ToANSI(RS.Fields("content").value)
  44. End If
  45.  
  46. RS.CloseRecordset
  47. Set RS = Nothing
  48. End Sub





Rate this topic:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Popularity: 1,780 views
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Comment



Mysql in visual basic Sample Source Code Copyright: You should confirm all information about Mysql in visual basic Sample Source Code full version edition(freeware/shareware) before downloading or relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators or key gen, cd key, hacks, dvd rip is illegal and prevent future development of Mysql in visual basic Sample Source Code full version edition. Download links are directly from our publisher sites or from the link provided by users, torrent files or links from rapidshare.com, yousendit.com, megaupload.com, netload.in, storage.to or depositfiles.com are not allowed.