944,008 Members | Top Members by Rank

Ad:
Nov 6th, 2008
0

converting this code from ms access to mysql

Expand Post »
Hi there

I was wondering if anybody knew how to change the below code (which currently defaults to a MS Access database) to a mysql database.

The below code is apart of a Caller ID software

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Private Sub OpenDataBase()
  3. Set fo = New FileSystemObject
  4. Set wrk = CreateWorkspace("", "admin", "", dbUseJet)
  5.  
  6. If Not fo.FileExists(m_stDataPath & "callerid.mdb") Then
  7. Set db = wrk.CreateDatabase(m_stDataPath & "callerid.mdb", dbLangGeneral)
  8. CreatePhoneDB
  9. Else
  10. Set db = wrk.OpenDataBase(m_stDataPath & "callerid.mdb")
  11. End If
  12. Set rs = db.OpenRecordset("PhoneCalls", dbOpenTable)
  13.  
  14. End Sub
  15.  
  16. Private Sub CloseDatabase()
  17. db.Close
  18. wrk.Close
  19. Set db = Nothing
  20. Set wrk = Nothing
  21. Set fo = Nothing
  22. End Sub
  23.  
  24.  
  25. Private Sub AddRecord()
  26. Dim lID As Long
  27. Select Case Len(frmLineInfo.Number.Text)
  28. Case 0
  29. frmLineInfo.Number.Text = "No Number"
  30. Case 1
  31. Select Case frmLineInfo.Number.Text
  32. Case "O"
  33. frmLineInfo.Number.Text = "Unavailable"
  34. frmLineInfo.CallName.Text = "Unavailable"
  35. Case "P"
  36. frmLineInfo.Number.Text = "Blocked"
  37. frmLineInfo.CallName.Text = "Blocked"
  38. End Select
  39. End Select
  40. Select Case Len(frmLineInfo.CallName.Text)
  41. Case 0
  42. frmLineInfo.CallName.Text = "-"
  43. Case 1
  44. Select Case frmLineInfo.CallName.Text
  45. Case "O"
  46. frmLineInfo.CallName.Text = "Unavailable"
  47. Case "P"
  48. frmLineInfo.CallName.Text = "Blocked"
  49. End Select
  50. End Select
  51.  
  52. With rs
  53. If (.RecordCount > 0) Then
  54. .MoveLast
  55. lID = .Fields("id") + 1
  56. Else
  57. lID = 1
  58. End If
  59. .AddNew
  60. .Fields("id") = lID
  61. .Fields("datetime") = Now
  62. .Fields("number") = frmLineInfo.Number.Text
  63. .Fields("name") = frmLineInfo.CallName.Text
  64. .Update
  65. End With
  66.  
  67. End Sub
  68.  
  69. Private Function CreatePhoneDB() As Recordset
  70. Dim tbl As TableDef
  71. Set tbl = db.CreateTableDef("PhoneCalls")
  72. With tbl
  73. .Fields.Append .CreateField("id", dbLong, 4)
  74. .Fields.Append .CreateField("datetime", dbDate, 4)
  75. .Fields.Append .CreateField("number", dbText, 20)
  76. .Fields.Append .CreateField("name", dbText, 20)
  77. db.TableDefs.Append tbl
  78. End With
  79. Set db = wrk.OpenDataBase(m_stDataPath & "callerid.mdb")
  80. Set tbl = db!phonecalls
  81. Set idx = tbl.CreateIndex("DateTime")
  82. idx.Fields.Append idx.CreateField("datetime")
  83. tbl.Indexes.Append idx
  84.  
  85.  
  86. End Function
  87.  
  88. Private Sub Report_Click()
  89. Load frmReport
  90. frmReport.Show
  91. End Sub
Similar Threads
Reputation Points: 14
Solved Threads: 0
Newbie Poster
psycho007 is offline Offline
23 posts
since Oct 2008
Nov 6th, 2008
0

Re: converting this code from ms access to mysql

Do you mean that instead of MS Access database as back-end, use the MS SQL? Weill if that's the case then you have to change the connecstring of the database
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Nov 7th, 2008
0

Re: converting this code from ms access to mysql

hi

yes thats what I mean, change the backend to mysql database :o)
Reputation Points: 14
Solved Threads: 0
Newbie Poster
psycho007 is offline Offline
23 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: help me about more coding in SQL code except (SELECT, INSERT, UPDATE & DELETE)
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: can't write a decimal to a recordset in VB 5.0





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC