converting this code from ms access to mysql

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 23
Reputation: psycho007 is an unknown quantity at this point 
Solved Threads: 0
psycho007 psycho007 is offline Offline
Newbie Poster

converting this code from ms access to mysql

 
0
  #1
Nov 6th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: converting this code from ms access to mysql

 
0
  #2
Nov 6th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 23
Reputation: psycho007 is an unknown quantity at this point 
Solved Threads: 0
psycho007 psycho007 is offline Offline
Newbie Poster

Re: converting this code from ms access to mysql

 
0
  #3
Nov 7th, 2008
hi

yes thats what I mean, change the backend to mysql database :o)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC