473,949 Members | 35,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADODB recordsets and connections

patjones
931 Recognized Expert Contributor
Hi -

I am just starting my study of ADO, and I have a purpose in my current project which seems to lend itself to using an ADODB recordset. The set up is this.

I have a table tblScreenShot that has three fields: fldTicketNum, fldScreenShotDe scription, and fldScreenShot. Basically, what this table will do is store screen shots (fldScreenShot is typed "OLE Object"). Perhaps 1 in 20 records in my project will necessitate a screen shot...so this table is where I want to store them.

Since screen shots take up so much memory, periodically I want to purge them from the database and put them in a separate file. Then, whenever the user needs to pull a record containing a screen shot - which won't be too often, the database can open the file back up and pull it out.

So, my first "shot in the dark" attempt at trying to save the contents of the table to a file goes something like this:

Expand|Select|Wrap|Line Numbers
  1.  Private Sub cmdSave_Click() 
  2.  
  3.     Dim rst As ADODB.Recordset
  4.     Dim strSQL As String
  5.  
  6.     Set rst = New ADODB.Recordset
  7.  
  8.     strSQL = "SELECT fldScreenShot, fldScreenShotDescription, fldTicketNum FROM tblScreenShot"
  9.  
  10.     rst.Open strSQL
  11.  
  12.     rst.Save "C:\Documents and Settings\Employee\Desktop\testScreenShot.adtg", adPersistADTG
  13.  
  14.     rst.Close
  15.  
  16.     Set rst = Nothing
  17.  
  18. End Sub
  19.  
When I attempt to run this, it stops at rst.Open strSQL, saying "Error 3709 - The connection cannot be used to perform this operation. It is either closed or invalid in this context."

For me, being new to ADO, this begs the question of what exactly a connection is, how it should be implemented here, and why it's needed in the first place.

Hopefully this isn't too big a can of worms, but if it is maybe my post can be used to teach the community here about some ADODB basics. Thanks so much.

Pat
Jan 8 '08
16 6230
ADezii
8,834 Recognized Expert Expert
Step 1 doesn't fix the problem, but I'm going to keep it in the code anyway. For step 2, I have tried .jpg and .gif; by this I mean that I tried changing the file extension on line 21 of my code to those extensions. "temp123465 " is the only file name that I have tried using. When I persist the recordset in XML format, the save operation still works fine, but the retrieval problem still exists.

I should point out that the retrieval itself seems to go fine, because when I do a Debug.Print on the two non-image fields in the retrieved record (a text field and a number field) I get the proper values in the Immediate Window. This is what leads me to believe, still, that there is an issue specifically with the way the image (fldScreenShot) is being written to the .adtg / .xml file...
See Post #10 for an Updated Reply.
Jan 11 '08 #11
patjones
931 Recognized Expert Contributor
See Post #10 for an Updated Reply.
I still get Error 2114...

The table that you save the image to, is that field typed as OLE Object? Because that's how I have my fldScreenShot typed...

Is it possible that I am having a problem with references? Perhaps there's a library that I don't have checked off which is preventing the code from running properly?
Jan 11 '08 #12
ADezii
8,834 Recognized Expert Expert
[quote=zepphead8 0]I still get Error 2114...

The table that you save the image to, is that field typed as OLE Object? Because that's how I have my fldScreenShot typed...
Yes. Was the Screen Shot originally saved as a BLOB?

Is it possible that I am having a problem with references?
Most definately, Error Number 2114 would point to that possibility. At a minimum, you would need References to:
  1. Microsoft Scripting Runtime
  2. Microsoft ActiveX Data Objects

P.S. - If your problems persist, would it be possible to send the Database to me, with a sub-set of the data, as an E-Mail Attachment?
Jan 11 '08 #13
patjones
931 Recognized Expert Contributor
[quote=ADezii]
I still get Error 2114...


Yes. Was the Screen Shot originally saved as a BLOB?


Most definately, Error Number 2114 would point to that possibility. At a minimum, you would need References to:
  1. Microsoft Scripting Runtime
  2. Microsoft ActiveX Data Objects
P.S. - If your problems persist, would it be possible to send the Database to me, with a sub-set of the data, as an E-Mail Attachment?
Well, I took the screen shot and pasted it into the table...not sure that it's in BLOB format necessarily. How do I verify that?

I made sure that I have Microsoft Scripting Runtime and Microsoft ActiveX Date Objects 2.8 Library referenced.

I have no problem emailing this to you...
Jan 11 '08 #14
ADezii
8,834 Recognized Expert Expert
[quote=zepphead8 0]

Well, I took the screen shot and pasted it into the table...not sure that it's in BLOB format necessarily. How do I verify that?

I made sure that I have Microsoft Scripting Runtime and Microsoft ActiveX Date Objects 2.8 Library referenced.

I have no problem emailing this to you...
Well, I took the screen shot and pasted it into the table...not sure that it's in BLOB format necessarily. How do I verify that?
You would have had to specifically Save it as a Binary Large Object with either ADO or DAO code, such as that provided for in the BLOBs Tip. Also, if you tried to activate the Object in Table View, you would receive a 'Communication Error with the Server or ActiveX Control'. It seems that this may be at the root of your problem.
Jan 11 '08 #15
patjones
931 Recognized Expert Contributor
[quote=ADezii]

You would have had to specifically Save it as a Binary Large Object with either ADO or DAO code, such as that provided for in the BLOBs Tip. Also, if you tried to activate the Object in Table View, you would receive a 'Communication Error with the Server or ActiveX Control'. It seems that this may be at the root of your problem.
Haven't tried these most recent suggestions yet, but will tomorrow! So much to do : - )
Jan 14 '08 #16
patjones
931 Recognized Expert Contributor
[quote=zepphead8 0]

Haven't tried these most recent suggestions yet, but will tomorrow! So much to do : - )
Hi:

I ended up modifying the project slightly in order to accomodate the easier method of having an Attachment field in the table, and linking to external .JPG files. The whole BLOB method seems very promising, and I'm sure I'll return to it eventually; I just don't need it right now.

Thanks so much for all your help, as usual...

Pat
Jan 25 '08 #17

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

Similar topics

4
1786
by: James | last post by:
Quick question about closing recordsets and connection objects. We're in the process of rewriting a TON of bad code. None of it is even remotely tabbed properly, it's impossible to read half the time and it never closes connection objects or recordsets. Unfortunately, I've been assigned the task of closing them. I assume I'm just doing: recordset.close Set recordset = Nothing conn.close
17
9602
by: Susan Bricker | last post by:
Hi. I am a relative "newbie" who has been asked to create a database for a Dog Competition Organization. I have created databases (for my use) just for fun to organize a practice Dog Obedience Competition another to organize those fun projects, I felt comfortable enough to tack a database for work to manage software releases (I'm a programmer for a major US Bank) for my department. I did this on my own time and "sold" it to my manager...
1
1424
by: jason | last post by:
hello, i have a C# class library that i recently had to add ADODB functionality to, in order to support consumer applications that can only work with recordsets. i added the ADODB library reference, and implemented recordsets without a problem, however now my class library dll won't register. when i attempt to register it with COM+, the MMC reports "could not find the file specified". since this occured right AFTER i added the ADODB
3
6638
by: | last post by:
Hello ppl, I have snippet that works fine udner ADODB with VB6, but something wrong with it in Vb.NET. Anyone can help? Recordset1 (ADODB.Recordset) Error: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. Error Source: SELECT * FROM Accounts
8
6711
by: Tull Clancey | last post by:
Hi, hope someone can help. I'm writing a decent size app as a first project in Net, have been writing in VB for years. I've stumbled on a small problem, I can't open two connections to a database at the same time, even if the connections are in different classes. Am I doing something compeltely idiotic or is this not as easy at it used to be? Cheers,
3
3887
by: Yuk Tang | last post by:
I'm trying to grab the fieldnames and values from a recordset, but I'm getting errors. I have an idea what the error might come from, but I'm not sure how to correct it. I'm connecting to an Access db which has the table 'Users', and I want to grab the fieldnames and values without necessarily knowing their numbers and formats. The msgboxes are there to illustrate the error. To run this, you need an Access db called Users.mdb in the...
6
5376
by: Wonder | last post by:
We have a VB.NET project with a reference to ADO 2.5 When I open it on my machine, I get the following build error: "The referenced component 'ADODB' has an updated custom wrapper available." When I double click on it, I get the following dialog appear: If I click 'No', for every object declared from the ADODB library, I get a build error as follows: "Reference required to assembly 'ADODB' containing the type 'ADODB.Connection'. Add...
7
319
by: Peter Newman | last post by:
Im still trying to get my head around this, but its the only way i have seen to be able to create a 'recordset' and bind text boxex to it and navigate throw each record by the click of a button ... ok it may not be the prettist of code but i have that bit working . i have however stumbled across another problem ... I make a connection to a SQL2005 database when my app loads using the following CON_BOSSCONNECTION.ConnectionString =
7
2923
by: boyleyc | last post by:
Hi all I have written a database in access and used ADODB recordsets all the way through. The only recordsets that are not ADODB are the listbox navigation code automatically generated by access 2003 as follows : ' Find the record that matches the control. Dim rs As Object Set rs = Me.Recordset.Clone
0
10171
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11363
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10701
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9903
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4547
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.