Can't Insert Large Files BLOB
Posted: Mon 31 Oct 2005 11:45
Hi~ I am register user ,Use 3.05 for .NET Framework 1.X Version
This is my code .when the picture is small size whe be fine
but when picture size more 300K will have error
coule tell me how to do it ..
thanks
Dim FileSize As Long
Dim rawData() As Byte
Dim fs As FileStream
'fs = New FileStream(Application.StartupPath & "\ICON.png", FileMode.Open, FileAccess.Read)
fs = New FileStream("E:\Picture\100_2530.JPG", FileMode.Open, FileAccess.Read)
Dim r As BinaryReader = New BinaryReader(fs)
'Dim myBlob As MySqlBlob = New MySqlBlob(r.ReadBytes(Convert.ToInt32(fs.Length)))
Dim myBlob As MySqlBlob = New MySqlBlob(r.ReadBytes(Convert.ToInt64(fs.Length)))
str_SQL = "Update m_program set picture1 = :picture1 Where pkey= '" & Pkey & "'"
Dim Command As MySqlCommand = New MySqlCommand(str_SQL, myConnection)
myConnection.Open()
Command.Parameters.Add("picture1", myBlob)
Command.ExecuteNonQuery()
myConnection.Close()
This is my code .when the picture is small size whe be fine
but when picture size more 300K will have error
coule tell me how to do it ..
thanks
Dim FileSize As Long
Dim rawData() As Byte
Dim fs As FileStream
'fs = New FileStream(Application.StartupPath & "\ICON.png", FileMode.Open, FileAccess.Read)
fs = New FileStream("E:\Picture\100_2530.JPG", FileMode.Open, FileAccess.Read)
Dim r As BinaryReader = New BinaryReader(fs)
'Dim myBlob As MySqlBlob = New MySqlBlob(r.ReadBytes(Convert.ToInt32(fs.Length)))
Dim myBlob As MySqlBlob = New MySqlBlob(r.ReadBytes(Convert.ToInt64(fs.Length)))
str_SQL = "Update m_program set picture1 = :picture1 Where pkey= '" & Pkey & "'"
Dim Command As MySqlCommand = New MySqlCommand(str_SQL, myConnection)
myConnection.Open()
Command.Parameters.Add("picture1", myBlob)
Command.ExecuteNonQuery()
myConnection.Close()