How to insert BLOB into MySQL using ODBC driver 3.51

How to insert BLOB into MySQL using ODBC driver 3.51

am 10.06.2006 06:57:29 von RAMANAIAH NAGINENI

I am facing problem in inserting BLOB into MySQL using ODBC driver 3.51. I
am working in C# dot net and my application is Windows application.
I await your suggestions in this regard to solve the problem.
Ramana

____________________________________________________________ _____
Cox & Kings presents ‘Win a trip for 2 to Austria’ Contest. Click here
http://www.coxandkings.com/cms/products/specialpromotions/?l ink=view&CM_ID=78


--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org

RE: How to insert BLOB into MySQL using ODBC driver 3.51

am 10.06.2006 13:05:13 von Tim Lucia

Here is a VB (ADO Record Sets) function I am currently using to insert blobs
in both MySQL and Oracle. It's not quite what you're looking for, but I
offer it in case it gives you some idea(s).

Tim


Private Function StoreBlobInDB(ByVal sDataSourceName As String, _
ByVal sBlobTable As String, _
ByVal sBlobColumn As String, _
ByVal sFilePath As String) As Integer

Dim conn As ADODB.Connection 'adodb connection variable
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset

Dim mystream As ADODB.Stream
Set mystream = New ADODB.Stream
mystream.Type = adTypeBinary
mystream.Open
mystream.LoadFromFile sFilePath

' See http://dev.mysql.com/doc/refman/5.0/en/connection-parameters .html
' for a description of the connection option values
' We require 1 + 2 + 8 + 32 + 2048 + 16384, which are set
' in the data source.

conn.ConnectionString = sDataSourceName
conn.CursorLocation = adUseClient
conn.Open

If conn.Properties("DBMS Name") = "MySQL" Then
rs.Open "SELECT * FROM " & sBlobTable & " WHERE 1=0", conn,
adOpenDynamic, adLockPessimistic
With rs
.AddNew
.fields(sBlobColumn) = mystream.Read
.Update
End With
rs.Close
rs.Open "SELECT LAST_INSERT_ID() AS ID"
Dim blobId As Integer
blobId = rs(0)
Else
If conn.Properties("DBMS Name") = "Orac" Then
Dim seq As String
seq = sBlobTable & "_SEQ.NEXTVAL"
rs.Open "SELECT " & seq & " AS ID FROM DUAL", conn,
adOpenDynamic, adLockPessimistic
blobId = rs(0)
rs.Close
rs.Open "SELECT * FROM " & sBlobTable & " WHERE 1=0", conn,
adOpenDynamic, adLockPessimistic
With rs
.AddNew
.fields(sBlobColumn) = mystream.Read
.fields("ID") = blobId
.Update
End With
Else
Err.Raise ERROR_DSN_NOT_SUPPORTED, "StoreBlobInDB", _
"Configuration error: DSN " & sDataSourceName & " is
unsupported. Type = " & _
conn.Properties("DBMS Name")
End If
End If


rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing

StoreBlobInDB = blobId

End Function

-----Original Message-----
From: RAMANAIAH NAGINENI [mailto:nagramana@hotmail.com]
Sent: Saturday, June 10, 2006 12:57 AM
To: myodbc@lists.mysql.com
Subject: How to insert BLOB into MySQL using ODBC driver 3.51

I am facing problem in inserting BLOB into MySQL using ODBC driver 3.51. I
am working in C# dot net and my application is Windows application.
I await your suggestions in this regard to solve the problem.
Ramana

____________________________________________________________ _____
Cox & Kings presents 'Win a trip for 2 to Austria' Contest. Click here
http://www.coxandkings.com/cms/products/specialpromotions/?l ink=view&CM_ID=7
8


--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=timlucia@yahoo.com


--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org