Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 27th, 2006, 10:51 AM
Nabi Bux Nabi Bux is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 18 Nabi Bux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 9 m 4 sec
Reputation Power: 0
How to save and retrieve picture from database acess2003

Hi every i have following code when i want to execute the program i gives me runtime error 545
Un able to bind field or data member"Picture"
my table have three field one is Pubid and othe txtdecription which hold text and third one Picture which is type OLE to hold picture pub when i excute i get above error please help
I m using office xp acess xp

visual basic code:Option Explicit
Private cn As ADODB.Connection
Private rs As ADODB.Recordset


Private Sub Command1_Click()
'making txtdescription show whats in the description field
rs.Fields("Description") = txtDescription.Text


rs.MovePrevious
'just to make sure your at the start and so you don't get that error.
If rs.BOF Then rs.MoveFirst

FillFields
End Sub

Private Sub Form_Load()

Set cn = New ADODB.Connection
'make this the path to the image database.
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= C:\picdata.mdb"
cn.Open
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\picdata.mdb;Persist Security Info=False

Set rs = New ADODB.Recordset
rs.Open "Table1", cn, adOpenKeyset, adLockPessimistic, adCmdTable


FillFields 'this is a sub that I'll explain later.
End Sub


Private Sub cmdPrevious_Click()
'making txtdescription show whats in the description field
rs.Fields("Description") = txtDescription.Text


rs.MovePrevious
'just to make sure your at the start and so you don't get that error.
If rs.BOF Then rs.MoveFirst

FillFields
End Sub




Private Sub cmdNext_Click()
'making txtdescription show whats in the description field
rs.Fields("Description") = txtDescription.Text

rs.MoveNext
If rs.EOF Then rs.MoveLast

FillFields

If rs.EOF Then
MsgBox "At last record" 'avoiding that nasty error.
End If
End Sub



Private Sub cmdDelete_Click() 'this will delete the entire record.
If Not (rs.BOF And rs.EOF) Then
rs.Delete
If Not (rs.BOF And rs.EOF) Then
rs.MoveNext
If rs.EOF Then rs.MoveLast
FillFields
End If
End If
End Sub

Private Sub cmdAdd_Click()
Dim bytData() As Byte
Dim strDescription As String

On Error GoTo err

With dlgAdd 'remember the common dialog box.
'filtering so only jpg's and gifs are shown!
.Filter = "Picture Files (*.jpg, *.gif)|*.jpg;*.gif"
.DialogTitle = "Select Picture" 'sets the title of it.
.ShowOpen 'show the open dialog box.

'bit to "convert" the image to binary.
Open .FileName For Binary As #1
ReDim bytData(FileLen(.FileName))
End With

Get #1, , bytData
Close #1

'show a input box to enter description to the description field.
strDescription = InputBox("Enter description.", "New Picture")

With rs
.AddNew
.Fields("Description") = strDescription 'adding record to db
.Fields("Picture").AppendChunk bytData ' Here error occur adding the picture to the db
.Update
End With

FillFields
Exit Sub
err:
If err.Number = 32755 Then 'simple error check.
Else
MsgBox err.Description
err.Clear
End If
End Sub


Public Sub FillFields()
If Not (rs.BOF And rs.EOF) Then
txtDescription.Text = rs.Fields("Description")
Set Image1.DataSource = rs 'setting image1's datasource
Image1.DataField = "Picture" 'set its datafield.
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing 'closing all connections.
End Sub

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > How to save and retrieve picture from database acess2003


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT