473,800 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple dataset update @ runtime not working

I have an MS Access DB with a table' Isometric' . One of the columns
is named 'Sheet'. I am doin a test to see if I can change a value in
the dataset and update the Access table with the DataAdapter.Upd ate
method. It is not working:

Dim con As System.Data.Ole Db.OleDbConnect ion = DAL.GetOLECon
Dim dap As New System.Data.Ole Db.OleDbDataAda pter("SELECT *
FROM Isometric", con)

Dim cmb As New System.Data.Ole Db.OleDbCommand Builder(dap)
Dim das As New DataSet

das.Tables(0).R ows(0).Item("Sh eet") = 999

dap.Update(das, "Isometric" )

Here is the error I get

Syntax error (missing operator) in query expression '((ID_Isometric =
?) AND ((? = 1 AND Line number IS NULL) OR (Line number = ?)) AND ((? =
1 AND Sheet IS NULL) OR (Sheet = ?)) AND ((? = 1 AND Spec IS NULL) OR
(Spec = ?)) AND ((? = 1 AND Material delivered IS NULL) OR (Material
delivered = ?)) AND ((? = 1'.

is the commandbuilder just creating the update commandtext inccorectly?

Nov 2 '06 #1
3 2000
On 1 Nov 2006 23:44:05 -0800, "Bryan" <br*******@gmai l.comwrote:
Dim con As System.Data.Ole Db.OleDbConnect ion = DAL.GetOLECon
Dim dap As New System.Data.Ole Db.OleDbDataAda pter("SELECT *
FROM Isometric", con)

Dim cmb As New System.Data.Ole Db.OleDbCommand Builder(dap)
Dim das As New DataSet

das.Tables(0).R ows(0).Item("Sh eet") = 999

dap.Update(das, "Isometric" )


You've created the connection object - is the connection open?
cmb OuotePrefix and QuoteSuffix?
I don't see where you have filled the adapter (dap)

Dim con As System.Data.Ole Db.OleDbConnect ion = DAL.GetOLECon

Dim dap As New System.Data.Ole Db.OleDbDataAda pter _
("SELECT * FROM Isometric", con)
Dim cmb As New System.Data.Ole Db.OleDbCommand Builder(dap)
cmb.QuotePrefix = "["
cmb.QuoteSuffix = "]"

Dim das As DataSet = New DataSet
If con.State = ConnectionState .Closed Then
con.Open()
End If
dap.Fill(das, "Isometric" )
If das.Tables(0).R ows.Count 0 Then
das.Tables(0).R ows(0).Item("Sh eet") = 999
dap.Update(das, "Isometric" )
End If
Gene
Nov 2 '06 #2
It was the QuotePrefix/Sufix. I am updating tables that users create,
so there is always the possibility of spaces & other bad characters in
column names.

I have been reading article after article, post after post about the
drawbacks of the ADO commandbuilder object, one of them being that it
can't work if your column names have spaces/bad characters in them. I
agree with most the criticism, but I am amazed that I havn't read about
the Quoteprefix/suffix thing before. As long as you know what your
back end uses to enclose column names in SQL, this is no longer a
problem. For the simple updating I was trying to do, this problem has
now gone away.
After reading your post I searched for articles that talk about the
Quoteprefix/suffix members and there didn't seem to be many relevant
ones that recognized the value of these members.
For simple dataset updates, in certain situations such as mine, the
quoteprefix/suffix members have made the commandbuilder object usefull
and will save me time.

Thanks for the help!

Nov 2 '06 #3
On 2 Nov 2006 12:50:27 -0800, "Bryan" <br*******@gmai l.comwrote:
>It was the QuotePrefix/Sufix. I am updating tables that users create,
so there is always the possibility of spaces & other bad characters in
column names.

I have been reading article after article, post after post about the
drawbacks of the ADO commandbuilder object, one of them being that it
can't work if your column names have spaces/bad characters in them. I
agree with most the criticism, but I am amazed that I havn't read about
the Quoteprefix/suffix thing before. As long as you know what your
back end uses to enclose column names in SQL, this is no longer a
problem. For the simple updating I was trying to do, this problem has
now gone away.
After reading your post I searched for articles that talk about the
Quoteprefix/suffix members and there didn't seem to be many relevant
ones that recognized the value of these members.
For simple dataset updates, in certain situations such as mine, the
quoteprefix/suffix members have made the commandbuilder object usefull
and will save me time.

Thanks for the help!

The example I gave was based on an example found in the Help File which includes the
quote prefix/sufix. I was intially using this sort of method, myself. But for some
reason (at least here), using the command builder and data adapter seems to have a
proportional performance hit the larger the data base. I have since modified my
project to use explicit UPDATE, INSERT, or DELETE commmands with Execute.NonQuer y()
which gives the same performace regardless of the database size.

Gene
Nov 3 '06 #4

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

Similar topics

13
4758
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is like this: %@ Language=VBScript %> <!--#include file="includes/openconnection.asp"-->
2
4828
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different row selected in the datagrid. I want to save the changes that user make in the textboxes when they select a different row in the datagrid. I tried capturing the textbox.text at datagrid's CurrentCellChanged event but by then the textbox.text...
5
2959
by: Wayne Wengert | last post by:
I am using VB ASP.NET. In my page I convert an uploaded XML file to a dataset as follows: Dim ds1 As DataSet = New DataSet ds1.ReadXml(strPathName, XmlReadMode.Auto) Now I want to append all the rows of ds1 to an existing table in an SQL Server database. I know I can do things like looping through the dataset and issuing Update SQL statements to do this but I suspect there is a better
15
2251
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
7
5266
by: Dan Sikorsky | last post by:
How do you iterate thru a dataset to change money fields to a different value? Here's what I have. My dataset is filled directly from a stored procedure. ' Create Instance of Connection and Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As New SqlDataAdapter("OrdersList", myConnection)
13
1836
by: Lars Netzel | last post by:
hi! myDataSet that is fillled from an Access 2000 db and includes ONE table From that Table in myDataSet I create myDataView and use a Rowfilter to get a few rows that i work with (i need a DataView cause I do a lot of filtering) The problem is the primary key field (a unique counter), let's call it "TBL_ID".
14
2134
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these grid and write to the database and I set the new Primary Keys and related Fields to the new asigned atuonumbers in the Access.
4
1854
by: Peter Proost | last post by:
Hello group, what would be the best way to do the next thing: I've got a grid form with about 15000 records, when I double click a row a detail form is opened and the user can modify and save the record, this all works just fine, then the user closes the detail form and ofcourse I want to show his modifications in the grid form, but now my question is what's the best way to do this without completely reloading the dataset that holds the...
6
1287
by: Arne Beruldsen | last post by:
I have a very simple Access data base. No new info is going to be added...the only changes are to existing fields. I have 2 tables both with one row each. I'm using vb.net. I can easily retrieve the data via "Reader"...but how to I update for changes? Thanks
0
9691
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
9551
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
10505
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...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10035
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
6813
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
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.