473,395 Members | 1,678 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,395 software developers and data experts.

Cannot update 1 of 2 tables - Dynamic SQL generation is not supported

Hi, I'm having a problem with my code,

I am doing the following - retrieving a field from a table, which is linked to another table, i'm only updating one of the fields in one of the two tables...

Expand|Select|Wrap|Line Numbers
  1. ##############
  2. Page Load Sub
  3.  
  4. sqlselect = "Select ProductID,Name,Price from Products,Store Where Products.StoreID = Store.StoreID And StoreID = 7"
  5.  
  6. connectionstring = dh.returnconnection # returns the connection string to the location of the database
  7.  
  8. sqlcon = new sqlconnection(connectionstring)
  9.  
  10. da = new sqlDataAdapter(sqlselect,connectionstring)
  11.  
  12. ds = new dataset()
  13.  
  14. dr = ds.Tables(0).Rows(0)
  15.  
  16. If NotPostBack Then
  17. tbPrice.Text = dr("Price")
  18. #etc...
  19. EndIf
  20.  
  21. End Sub
  22. ##############
  23.  
  24. ##############
  25. Submit Button "Protected Sub "SubButton""
  26.  
  27. dr.BeginEdit()
  28.  
  29. dr("Price") = tbPrice.Text
  30.  
  31. dr.EndEdit()
  32.  
  33. Dim objCommandBuilder As New SqlCommandBuilder(da)
  34.  
  35. da.Update(ds, 0)
  36.  
  37. End of sub etc..
  38. #############

The code breaks at the line
"da.Update(ds, 0)", with the error -

invalidOperationException was unhandled by the user code
Dynamic SQL generation is not supported against multiple base tables.

This is because I'm doing a link between tables in my sql and the dataadapter is looking for a table to reference (well, i assume this is the problem),
however i've heard of different ways to remedy this e.g do a seperate dataadapter for updating or something.. but i really wouldnt know how to do this, so if someone could have a look at my code, and show me how i could go about this, or another way (being a newbie of .net i'm learning as i'm going along) i'd be really grateful!
Jan 14 '08 #1
0 1335

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

Similar topics

1
by: Wing | last post by:
Hi all, I have created 2 tables in sql database and join these 2 tables before assign the result to the dataset, and display the result in datagrid. Everything is fine up to this point. The...
1
by: Foef | last post by:
When I have a stored procedure, with multiple tables in MS Access, in a dataset and I change it in my DataGrid, I get the next message when I want to update my DataSet: ...
1
by: John | last post by:
I'm tring to update my Table which haven't a primary key from a DataGrid but I'm having the following error"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand...
6
by: shil | last post by:
Hi, I am writing a windows app in .net 2003. I have a datagrid which gets data from a storedprocedure. My question is how can I update the data in the datagrid? I want to call another...
1
by: andrewcw | last post by:
I have just 1 table that I am updating, the SQL I use to generate the DataTable is complex using multiple tables, however when I view the fieldnames of the DataTable from the DataSet - everything...
2
by: nannu | last post by:
m using this code :........................... ======================================================================= OleDbConnection con =new OleDbConnection...
1
by: pieandpeas | last post by:
Hi, I'm having a problem with my code, I am doing the following - retrieving a field from a table, which is linked to another table, i'm only updating one of the fields in one of the two tables......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.