473,288 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

sqladapter caching data?

I am having a problem reading a simple update to the database. Basically
I'm testing a small change to the pubs database -- changing the price of the
Busy Executive's Database Guide from 19.99 to 1997 and back. Unfortunately,
it seems does reflect the change on my web form. Perhaps it's caching the
data retrieved by the SQLDataAdapter? (All of my code is generated by
VS.NET '03.

FYI, it works fine when I test on my developer workstation and database
LocalHost. It's only when I run the application on my development box that
it fails to "notice" the updates. I'm using the "copy project" method to
move it over.

----------------
Public Class Component1
Inherits System.ComponentModel.Component
#Region " Component Designer generated code "
Public Sub New(ByVal Container As System.ComponentModel.IContainer)
MyClass.New()
'Required for Windows.Forms Class Composition Designer support
Container.Add(Me)
End Sub
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Component overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1
Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "titles", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("title_id", "title_id"), New
System.Data.Common.DataColumnMapping("title", "title"), New
System.Data.Common.DataColumnMapping("price", "price"), New
System.Data.Common.DataColumnMapping("notes", "notes"), New
System.Data.Common.DataColumnMapping("pubdate", "pubdate")})})
Me.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1
'
'SqlDeleteCommand1
'
Me.SqlDeleteCommand1.CommandText = "DELETE FROM titles WHERE (title_id =
@Original_title_id) AND (notes = @Original_n" & _
"otes OR @Original_notes IS NULL AND notes IS NULL) AND (price =
@Original_price " & _
"OR @Original_price IS NULL AND price IS NULL) AND (pubdate =
@Original_pubdate) " & _
"AND (title = @Original_title)"
Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_titl e_id",
System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "title_id",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_note s",
System.Data.SqlDbType.VarChar, 200, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "notes",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_pric e",
System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, False,
CType(0, Byte), CType(0, Byte), "price",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_pubd ate",
System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "pubdate",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_titl e",
System.Data.SqlDbType.VarChar, 80, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "title",
System.Data.DataRowVersion.Original, Nothing))
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString =
"server=2k01;uid=sa;pwd=mypassword;database=pu bs"
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "INSERT INTO titles(title_id, title,
price, notes, pubdate) VALUES (@title_id, @ti" & _
"tle, @price, @notes, @pubdate); SELECT title_id, title, price, notes,
pubdate FR" & _
"OM titles WHERE (title_id = @title_id)"
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@title_id",
System.Data.SqlDbType.VarChar, 6, "title_id"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@title", System.Data.SqlDbType.VarChar,
80, "title"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@price", System.Data.SqlDbType.Money, 8,
"price"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@notes", System.Data.SqlDbType.VarChar,
200, "notes"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@pubdate",
System.Data.SqlDbType.DateTime, 8, "pubdate"))
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT title_id, title, price, notes,
pubdate FROM titles"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'SqlUpdateCommand1
'
Me.SqlUpdateCommand1.CommandText = "UPDATE titles SET title_id = @title_id,
title = @title, price = @price, notes = @" & _
"notes, pubdate = @pubdate WHERE (title_id = @Original_title_id) AND (notes
= @Or" & _
"iginal_notes OR @Original_notes IS NULL AND notes IS NULL) AND (price =
@Origina" & _
"l_price OR @Original_price IS NULL AND price IS NULL) AND (pubdate =
@Original_p" & _
"ubdate) AND (title = @Original_title); SELECT title_id, title, price,
notes, pub" & _
"date FROM titles WHERE (title_id = @title_id)"
Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@title_id",
System.Data.SqlDbType.VarChar, 6, "title_id"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@title", System.Data.SqlDbType.VarChar,
80, "title"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@price", System.Data.SqlDbType.Money, 8,
"price"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@notes", System.Data.SqlDbType.VarChar,
200, "notes"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@pubdate",
System.Data.SqlDbType.DateTime, 8, "pubdate"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_titl e_id",
System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "title_id",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_note s",
System.Data.SqlDbType.VarChar, 200, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "notes",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_pric e",
System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, False,
CType(0, Byte), CType(0, Byte), "price",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_pubd ate",
System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "pubdate",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_titl e",
System.Data.SqlDbType.VarChar, 80, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "title",
System.Data.DataRowVersion.Original, Nothing))
End Sub
#End Region
Public Sub FillDataSet(ByVal dSet As MyDataSet)
SqlDataAdapter1.Fill(dSet)
End Sub
End Class

_____
DC G
Nov 20 '05 #1
5 1768
* "DC Gringo" <dc******@visiontechnology.net> scripsit:
I am having a problem reading a simple update to the database. Basically
I'm testing a small change to the pubs database -- changing the price of the
Busy Executive's Database Guide from 19.99 to 1997 and back. Unfortunately,
it seems does reflect the change on my web form. Perhaps it's caching the
data retrieved by the SQLDataAdapter? (All of my code is generated by
VS.NET '03.


Post this question in the ADO.NET group, there you will more likely get
an answer:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Cor
Hi DC Gringo,

Did you put your adapter.update in a try catch end try block.
Try
da.Fill(ds)
Catch sqlExc As SqlClient.SqlException
messagebox.show(sqlExc.ToString) 'for a windowsform
Catch exc As Exception
messagebox.show(exc.ToString) ' for a windowsform
Finally
conn.Close()
End Try
End If

I am having a problem reading a simple update to the database. Basically
I'm testing a small change to the pubs database -- changing the price of the Busy Executive's Database Guide from 19.99 to 1997 and back. Unfortunately, it seems does reflect the change on my web form. Perhaps it's caching the
data retrieved by the SQLDataAdapter? (All of my code is generated by
VS.NET '03.

FYI, it works fine when I test on my developer workstation and database
LocalHost. It's only when I run the application on my development box that it fails to "notice" the updates. I'm using the "copy project" method to
move it over.

Nov 20 '05 #3
Actually, what I'm doing is making changes directly to the database via
Enterprise Manager (not via VB code)...then refreshing my browser.

_____
DC G

"Cor" <no*@non.com> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Hi DC Gringo,

Did you put your adapter.update in a try catch end try block.
Try
da.Fill(ds)
Catch sqlExc As SqlClient.SqlException
messagebox.show(sqlExc.ToString) 'for a windowsform
Catch exc As Exception
messagebox.show(exc.ToString) ' for a windowsform
Finally
conn.Close()
End Try
End If

I am having a problem reading a simple update to the database. Basically I'm testing a small change to the pubs database -- changing the price of

the
Busy Executive's Database Guide from 19.99 to 1997 and back.

Unfortunately,
it seems does reflect the change on my web form. Perhaps it's caching the data retrieved by the SQLDataAdapter? (All of my code is generated by
VS.NET '03.

FYI, it works fine when I test on my developer workstation and database
LocalHost. It's only when I run the application on my development box

that
it fails to "notice" the updates. I'm using the "copy project" method to move it over.


Nov 20 '05 #4
Cor
Hi DC,

Than I think you are probably doing the updates on the wrong server.

The pubs database is maybe several times installed.

Cor
Nov 20 '05 #5
Must have been...I tried it again this morning with no problem. <doink!!!>

Thanks for listening!
_____
DC G

"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi DC,

Than I think you are probably doing the updates on the wrong server.

The pubs database is maybe several times installed.

Cor

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Newbee Adam | last post by:
how to save textbox values to 2 tables using sqladapter I am new with this. Do I need to ADO.net? what is the simplist correct way? or can I write a query in my vb.net form insert table...
6
by: kevin | last post by:
Could someone explain, Caching. I understand Caching as simply saving a copy of something that is unlikely to change and to which you frequently refer as opposed to retrieving a fresh copy every...
0
by: Martin | last post by:
Hi. I had a very frustrating afternoon and evening but I have got it all under control now so all of a sudden I am in a good mood. I want to share some insights on output caching with you lot. ...
10
by: BillGatesFan | last post by:
I'm trying to understand ASP.NET caching. I set the Page Output directive to VaryByParams= None and the duration = 60. Now whenever users hit my web app they can see each others data. Is there...
4
by: DylanM | last post by:
I've seen a few examples on how to cache data in a WinForms GUI, just after some thought on the best solution. The data I'm trying to cache will be generally be small collections of Business...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
1
by: Hrvoje Voda | last post by:
How to refresh dataset and sqladapter after using store procedure? I tried to call update on sqladapter but it doesn't work. Only when I close program and call it again a change is visible. Hrcko
2
by: George1776 | last post by:
All, I've recently upgraded our production ASP.NET/C# application from framework 1.1 to 2.0. Since then I've been plagued by out-of-memory errors and problems with the cache object (which may...
3
by: Gary W. Smith | last post by:
I had a couple questions about data caching. We have a site that gets a huge amount of traffic to a few specific pages that have a lot of data on them (300k hits/hour during peak, about 6-10 data...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.