Quelqu'un at-il du code VBA qui va stocker un tableau d'octets dans une colonne blob MySQL?Stocker un tableau d'octets dans MySQL Blob avec VBA
1
A
Répondre
2
Voici du code. Nécessite une référence à la bibliothèque Microsoft Active Data Objects 2.x. Il utilise le fournisseur OLE DB pour MySQL (peut-être besoin d'installer cela sur la machine client).
Sub StoreBLOB(data() As Byte, key As Double)
'stores the BLOB byte array into the row identified by the key
'requires reference to Microsoft Active Data Objects 2.x Library
On Error GoTo handler:
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim conStr As String
Dim strSQL As String
'have it return only the record you want to store your blob
strSQL = strSQL & "SELECT * FROM YOURTABLE WHERE KEY = " & key
'setup connection
conStr = conStr & "Provider=MySQLProv;"
conStr = conStr & "Data Source=mydb;"
conStr = conStr & "User Id=myUsername;"
conStr = conStr & "Password=myPassword;"
con.ConnectionString = conStr
con.Open
rs.Open strSQL, con, adOpenDynamic, adLockOptimistic
If rs.RecordCount > 1 Then
Err.Raise 1001, "StoreBLOB", "Too many records returned from dataset. Check to make sure you have the right key value"
Else
Err.Raise 1002, "StoreBLOB", "No Records found that match the key"
End If
rs.Fields("BLOBFIELDNAME").Value = data
rs.Update 'store the contents to the database
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
Exit Sub
handler:
Err.Raise 1003, "StoreBLOB", "Unexpected Error in StoreBLOB. Check that server is running"
End Sub
0
En supposant que vous utilisez ADO pour accéder à mysql, il y a un KB article on the subject.
Questions connexes
- 1. Stocker un tableau binaire dans MySQL
- 2. Comment stocker un tableau dans mysql?
- 3. stocker un pdf dans mysql
- 4. Stocker JSON dans MySQL?
- 5. Comment stocker un tableau d'octets dans Oracle?
- 6. Comment stocker un BLOB dans une base de données?
- 7. Insérer une image de tableau d'octets dans Word VBA
- 8. objets BLOB Chargement dans un tableau dans l'iPhone
- 9. Comment stocker une image dans MySQL?
- 10. Problème BLOB mysql
- 11. Recevoir un tableau Jagged dans VBA (VB6)
- 12. Extraire MySQL Blob et ajouter au tableau PHP?
- 13. VBA, un tableau en ligne
- 14. Stocker des objets dans un tableau avec php
- 15. Remplacer un mot dans le texte BLOB par MySQL
- 16. Stocker des pixels dans un tableau d'octets
- 17. Comment stocker SDL_Color dans un tableau C++?
- 18. Comment stocker un fichier zip dans MySQL?
- 19. PHP/mysql: interroger MySQL avec un tableau et obtenir des résultats dans un tableau
- 20. VBA Word: Tableau légende
- 21. Comment coder un blob binaire en tant que blob Unicode?
- 22. tableau dans MySQL
- 23. stocker des données binaires dans mysql
- 24. Comment stocker des données dans un tableau dans une fonction ou une procédure mysql
- 25. PHP MYSQL télécharger le fichier et stocker en tant que blob
- 26. MySQL donne un tableau avec PHP?
- 27. Zip HTML/PDF, stocker en tant que Blob
- 28. Quel est le meilleur moyen de stocker et de récupérer un tableau dans PHP/MySQL DB
- 29. tableau Blob octets en XML à l'image
- 30. Stocker du XML dans Mysql
Peut intéresser: http://stackoverflow.com/questions/3363864/is-there-equivalent-code-in-vba-access-2007/3364275#3364275 – Fionnuala