Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2006, 02:55 AM
FredG
Guest
 
Posts: n/a
Default Caching problem?

I'm writing vb.net code with MS Access as the database using
OleDbConnection. The problem I'm having is, I write to the database
then I read back what I just wrote. The read appears to be from an
older cached version because I get the previous results. If I read
twice I usually get the correct results. Any ideas on how to suppress
this?

thanks,

fg

  #2  
Old November 13th, 2006, 08:25 PM
RoyVidar
Guest
 
Posts: n/a
Default Re: Caching problem?

"FredG" <fguyton@gmail.comwrote in message
<1163387461.066392.91120@h48g2000cwc.googlegroups. com>:
Quote:
I'm writing vb.net code with MS Access as the database using
OleDbConnection. The problem I'm having is, I write to the database
then I read back what I just wrote. The read appears to be from an
older cached version because I get the previous results. If I read
twice I usually get the correct results. Any ideas on how to
suppress this?
>
thanks,
>
fg
Technically, you are not using Access as database, but Jet ;-)

The behaviour is known when using ADO connection, and here is a
Microsoft KB article on that http://support.microsoft.com/kb/200300.
How or if this relates to .Net, I don't know. If you don't get any
ansvers, then I suggest trying an NG dedicated to VB.Net.

--
Roy-Vidar


  #3  
Old November 13th, 2006, 09:05 PM
rich w
Guest
 
Posts: n/a
Default Re: Caching problem?

Hi Fred,

Here is what I do to read from an Access MDB into a VB.Net app which
does not seem to have any issues:

Imports System.Data.OleDB

Public Class Form1
Private Button1_Click(...) handles Button1.Click
Dim Conn As New OleDBConnection("Provider=Microsoft.Jet.OLED.4.0;
Data Source="C:\test1.mdb;")
Dim da As New OleDbDataAdapter, ds As New Dataset
da.SelectCommand = New OleDbCommand
da.SelectCommand.Connection = conn
da.SelectCommand.CommandTye = CommandType.Text
da.SelectCommand.CommandText = "Select * from Table1"
da.Fill(ds, "tbl1")
dgrv1.DataSource = ds.Tables("tbl1")
End Sub
End Class

dgrv1 is a datagridview that I use to display the data from my test
table in the Access mdb called Table1. I alias this table in the VB.Net
app as "tbl1" (for distinguishing purposes). If you want to read back a
specific row, just change the commandText in the select command like

Select * from Table1 Where ID = 5

You could also use a straight forward command object instead of a
dataAdapter, but the dataAdapter has a lot more methods/properties built
into it than the command object. It encapsulates more stuff - like
dealing with apostrophes, particularly in parameters.

Regards,
Rich


*** Sent via Developersdex http://www.developersdex.com ***
 

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles