Expand|Select|Wrap|Line Numbers
- Private Sub Command1_Click()
- Set cn = New ADODB.Connection
- cn.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _
- "Data Source=localhost;Initial Catalog=testdb"
- Set rs = New ADODB.Recordset
- rs.Open "Select * from album", cn, adOpenKeyset, adLockOptimistic
- Set mstream = New ADODB.Stream
- mstream.Type = adTypeBinary
- mstream.Open
- mstream.LoadFromFile "C:\Users\Chris\Desktop\sample.jpg"
- rs.Fields("picture").Value = mstream.Read
- rs.Update
- rs.Close
- cn.Close
- End Sub
Expand|Select|Wrap|Line Numbers
- Dim cn As ADODB.Connection
- Dim rs As ADODB.Recordset
- Dim mstream As ADODB.Stream
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.