By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,491 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,491 IT Pros & Developers. It's quick & easy.

help with changing code from access to mysql database

P: 17
Hi

I have a caller ID software that I would like to change from Microsoft Access database to Mysql and was wondering if somebody could help me. The code i currently have is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub OpenDataBase()
  3.     Set fo = New FileSystemObject
  4.     Set wrk = CreateWorkspace("", "admin", "", dbUseJet)
  5.      If Not fo.FileExists(m_stDataPath & "callerid.mdb") Then
  6.         Set db = wrk.CreateDatabase(m_stDataPath & "callerid.mdb", dbLangGeneral)
  7.         CreatePhoneDB
  8.     Else
  9.         Set db = wrk.OpenDataBase(m_stDataPath & "callerid.mdb")
  10.     End If
  11.     Set rs = db.OpenRecordset("PhoneCalls", dbOpenTable)
  12.  End Sub
  13.  Private Sub CloseDatabase()
  14.     db.Close
  15.     wrk.Close
  16.     Set db = Nothing
  17.     Set wrk = Nothing
  18.     Set fo = Nothing
  19. End Sub
  20.   Private Sub AddRecord()
  21.     Dim lID As Long
  22.     Select Case Len(frmLineInfo.Number.Text)
  23.       Case 0
  24.         frmLineInfo.Number.Text = "No Number"
  25.       Case 1
  26.         Select Case frmLineInfo.Number.Text
  27.           Case "O"
  28.             frmLineInfo.Number.Text = "Unavailable"
  29.             frmLineInfo.CallName.Text = "Unavailable"
  30.           Case "P"
  31.             frmLineInfo.Number.Text = "Blocked"
  32.             frmLineInfo.CallName.Text = "Blocked"
  33.        End Select
  34.     End Select
  35.     Select Case Len(frmLineInfo.CallName.Text)
  36.       Case 0
  37.         frmLineInfo.CallName.Text = "-"
  38.       Case 1
  39.         Select Case frmLineInfo.CallName.Text
  40.           Case "O"
  41.             frmLineInfo.CallName.Text = "Unavailable"
  42.           Case "P"
  43.             frmLineInfo.CallName.Text = "Blocked"
  44.         End Select
  45.     End Select
  46.      With rs
  47.         If (.RecordCount > 0) Then
  48.             .MoveLast
  49.             lID = .Fields("id") + 1
  50.         Else
  51.             lID = 1
  52.         End If
  53.         .AddNew
  54.         .Fields("id") = lID
  55.         .Fields("datetime") = Now
  56.         .Fields("number") = frmLineInfo.Number.Text
  57.         .Fields("name") = frmLineInfo.CallName.Text
  58.         .Update
  59.     End With
  60.  End Sub
  61.  Private Function CreatePhoneDB() As Recordset
  62.     Dim tbl As TableDef
  63.     Set tbl = db.CreateTableDef("PhoneCalls")
  64.     With tbl
  65.         .Fields.Append .CreateField("id", dbLong, 4)
  66.         .Fields.Append .CreateField("datetime", dbDate, 4)
  67.         .Fields.Append .CreateField("number", dbText, 20)
  68.         .Fields.Append .CreateField("name", dbText, 20)
  69.         db.TableDefs.Append tbl
  70.     End With
  71.     Set db = wrk.OpenDataBase(m_stDataPath & "callerid.mdb")
  72.     Set tbl = db!phonecalls
  73.     Set idx = tbl.CreateIndex("DateTime")
  74.     idx.Fields.Append idx.CreateField("datetime")
  75.     tbl.Indexes.Append idx
  76.   End Function
  77.  
  78.  
  79.  
Nov 11 '08 #1
Share this Question
Share on Google+
4 Replies


debasisdas
Expert 5K+
P: 8,127
try to use ADODB library for the purpose.
Nov 11 '08 #2

P: 17
Sorry im a php coder not a VB6 coder. I was wondering if you could be a little more specific? any links for this would be appreciated.

Thanks
Nov 11 '08 #3

debasisdas
Expert 5K+
P: 8,127
you mean to say all the code you have posted is in PHP ?

why you have posted the question here , why not in PHP forum ?
Nov 11 '08 #4

P: 17
no the code is vb6 no php. the vb6 code needs changing from a access database to mysql database
Nov 11 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.