good ways to use recordsets without autocommit? 
Author Message
 good ways to use recordsets without autocommit?

The short form of the question is, "How do I create an updatable recordset
and limit it such that it only updates the database when I tell it to?"

This should be a fairly simple thing in principle, but going through online
help and various books, it seems completely impossible.  The Microsoft tech
note (< http://www.*-*-*.com/ ;) on
VB Data controls and paused commitment looks promising, but I want to be
able to do this with recordsets I create and attach to generic ODBC
databases.  Normally when you open a recordset, it's either completely
unchangeable or automatically updating.  Where's the happy middle ground?

I'm also wondering how I can use the spiffy databound controls with any
ODBC database I choose -- how do you bind the Data control when you can't
set .database to a database you've opened? -- but I imagine I'll figure
that out.  Is there a particular reason why the language makes this
difficult to do?

Emailed responses are better than posts, but I'll come back and check
periodically.  Advice would be much appreciated.

Michael
--




Sat, 20 May 2000 03:00:00 GMT  
 good ways to use recordsets without autocommit?

Hi,

I am not too sure here...

With RDO Resultsets you can open a resultset as rdconcurBatch.
Using this you can have a totally disassociated resultset. IE You can
actually disconnect the Database connection, continue with
Insert/Delete/Update operations and then reconnect and perform a
BatchUpdate which will send everything over.

This should be possible through a RecordSet. If it is not possible then use
RDO resultsets they are much more flexible.

Hope this helps.
--
Euan deKock
Gekko Services (Pvt) Ltd



Quote:
> The short form of the question is, "How do I create an updatable
recordset
> and limit it such that it only updates the database when I tell it to?"



Sun, 21 May 2000 03:00:00 GMT  
 good ways to use recordsets without autocommit?


Quote:

>> The short form of the question is, "How do I create an updatable recordset
>> and limit it such that it only updates the database when I tell it to?"

>I ended up abandoning the Data control for this reason, among others. In
>contrast, you have complete control over the transaction commits and
>rollbacks if you use Recordset objects and OpenRecordset. There's more
>work involved, but it's possible to do it generically even in VB3. It
>should be even easier to do it with VB4 and VB5's ability to create OLE
>and ActiveX components.


suggested doing something involving opening the recordset a batch mode had
the right idea.  (In short, make sure the workspace DefaultCursorDriver is
dbUseClientBatchCursor, the recordset is opened with the dbOptimisticBatch
option, and then updates affect the local recordset, update dbUpdateBatch
commits to the database.)  It doesn't behave exactly like I'd expect --
other recordsets opened in dynaset batch mode don't have records
automatically modified upon database commit -- but it seems difficult to
have both batch updating and automatic data refresh, so I'm fine with that.

But now, I just want to know why Visual Basic (5.0, Enterprise ed.) crashes
_every time_ I open up a second project.  Whether I explicitly close the
first one or not, whether or not I open it via the 'Existing...' menu or
locate the file manually, whatever.  It gives me the by-now charming
message:

         Instruction at "0x0052de99" referenced memory at "0x00000000".
         The memory could not be "read".  

And, of course, it's terminate or debug from there.

It's always the same memory address, and it always tries to dereference
null.  And installing the Dev Studio service pack 3 did nothing to solve
it, sadly enough.  Has any one had this problem?

Michael
--




Mon, 22 May 2000 03:00:00 GMT  
 good ways to use recordsets without autocommit?

Quote:

> I'm also wondering how I can use the spiffy databound controls with any
> ODBC database I choose -- how do you bind the Data control when you can't
> set .database to a database you've opened? -- but I imagine I'll figure
> that out.  Is there a particular reason why the language makes this
> difficult to do?

Just set the Recordset property only, the database property of datactl
will reflect the proper database.

At design time:
1)Place text box on form (Text1)
1)Place a datactl (Data1) on the form. Don't set any properties.
2)Link the (Text1) boundctl's "DataSource" property to the
datactl(Data1).

At runtime:

'Basically do this
'Open your database.
'Open your recordset of interest from that database.
'set data1.recordset=yourrecordset
'let yourctl.DataField="FieldNameToBindTo"
'clean up at end

Quote:
>>>>>>>>>>>> EXAMPLE >>>>>>>>>>>>>>>>>>>>>>>>>

Dim db As Database  'Global
Dim rs As Recordset 'Global

Private Sub Form_Load()
        Set db = DBEngine.Workspaces(0).OpenDatabase("c:\mydbase.mdb")
        Set rs = db.OpenRecordset("myTableOrSQLstatement")
        Text1.DataField = "MyFieldName" 'Or whatever bound control
        Set Data1.Recordset = rs
End Sub

Private Sub Form_Unload(Cancel As Integer)
        Set Data1.Recordset = Nothing
        rs.Close
        db.Close
        Set rs = Nothing
        Set db = Nothing
End Sub

Have fun!

Craig Luna



Mon, 22 May 2000 03:00:00 GMT  
 good ways to use recordsets without autocommit?

Quote:

>But now, I just want to know why Visual Basic (5.0, Enterprise ed.) crashes
>_every time_ I open up a second project.  Whether I explicitly close the
>first one or not, whether or not I open it via the 'Existing...' menu or
>locate the file manually, whatever.  It gives me the by-now charming
>message:

>         Instruction at "0x0052de99" referenced memory at "0x00000000".
>         The memory could not be "read".  

>And, of course, it's terminate or debug from there.

There might be a corrupt FRX file being loaded by the project.
Have you tried different second projects?

When I had a bad FRX file, it would give me a similar error.


- Code Gurus: Custom solutions programmed for your business.
- Fair rates, fast response, rock-solid code. Initial consultation free.
- Visual Basic, Relational databases, Java, Internet programming, we do it all.



Tue, 23 May 2000 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. good ways to use recordsets without autocommit?

2. Help Please Topmost A;ways, Without Focus on click

3. dropdownlists and grids, which ways is the best?

4. Better ways to schedule?

5. Better ways to put text into textbox??

6. ADO without using ADODC....better??

7. Different ways to open a Recordset

8. Q] Retrieving a single value without using Recordset

9. How to create Data Report groups without using hierarchical recordsets

10. Using a RecordSet without an ADO connection

11. How to create a RecordSet in C, without using MFC

12. Using MSHFlexGrid without a recordset

 

 
Powered by phpBB® Forum Software