473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB6, MySql, Stream Image to Blob, Null Value Error

With a single record in my table, I can use this code:


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  
  3. Set cn = New ADODB.Connection
  4. cn.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _
  5.       "Data Source=localhost;Initial Catalog=testdb"
  6.  
  7. Set rs = New ADODB.Recordset
  8. rs.Open "Select * from album", cn, adOpenKeyset, adLockOptimistic
  9.  
  10. Set mstream = New ADODB.Stream
  11. mstream.Type = adTypeBinary
  12. mstream.Open
  13. mstream.LoadFromFile "C:\Users\Chris\Desktop\sample.jpg"
  14. rs.Fields("picture").Value = mstream.Read
  15. rs.Update
  16.  
  17. rs.Close
  18. cn.Close
  19.  
  20. End Sub
My general declarations:


Expand|Select|Wrap|Line Numbers
  1. Dim cn As ADODB.Connection
  2. Dim rs As ADODB.Recordset
  3. Dim mstream As ADODB.Stream 
When the command is pressed the same record obviously would update with a different picture (assuming I change the file path of course). I do not get a null error there.

I would like to constantly add a new record instead of updating the same one.

If I use rs.AddNew just above, "rs.Fields("picture").Value = mstream.Read"

I get the null value error. It says that the column "picture" cannot have a null value. Can someone please help me?

Thanks for the attention.
Nov 8 '08 #1
0 3705

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

Similar topics

3
by: Sugapablo | last post by:
Is there any PHP function that will allow me to determine the MIME type of a blob stored in MySQL? Specifically, if I'm storing an image as a blob in MySQL, is there any PHP function that can...
2
by: Jasper Bryant-Greene | last post by:
I have a database of movie titles, with about 78,000 records, and a database of related people (directors, writers, actors/actresses etc.) with about 141,000 records. I display a random movie out...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
by: shridhar_km | last post by:
Hi all, I am using OleDbConnection for connecting with MySQL.Using INSERT query for inserting images to MySQL db with C# code. The code is given below : string...
10
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't...
6
by: Phil | last post by:
Hi I have an issue when trying to stream blob image data from a SQL table to a .aspx page. the code I have works for GIF and JPEG but the images can be multiple pages and we would like them to open...
7
by: greywire | last post by:
So I need to load lots of data into my database. So I discover LOAD DATA INFILE. Great! This little gem loads my CSV in blazing times (compared to parsing the file and doing INSERT for each...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.