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

Help with Error - ( UPDATE DataTable ) does not make sense to me.

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 matches: What dont
I understand here:
( The error I get is : Dynamic SQL generation is not supported against
multiple base tables ). But My DataSet is 1 Table, and my target is 1 table,
Why the error ??
Thanks :
try
{
staticSQLConn.Open();
System.Data.SqlClient.SqlDataAdapter daAdapter = new
SqlDataAdapter(sSQL, staticSQLConn);
daAdapter.AcceptChangesDuringFill = false;
daAdapter.Fill(ds, srcTable); // all entries will be
flagged new

if (ds.HasChanges())
{
rowsToInsert = ds.Tables[srcTable].Rows.Count;
SqlCommandBuilder Cb = new SqlCommandBuilder(daAdapter);
Cb.GetInsertCommand();
DataTable dt = ds.Tables[srcTable];
retVal = daAdapter.Update(dt); // ERROR

}


--
Andrew
May 7 '06 #1
1 2065
Actually I have an answer, close the existing adapter that made the complex
query and then reopen a new adapter with Select * from source table as
follows:

if (ds.HasChanges())
{
rowsToInsert = ds.Tables[srcTable].Rows.Count;
DataTable dt = ds.Tables[srcTable];
daAdapter.Dispose();
System.Data.SqlClient.SqlDataAdapter daAdapter2 = new
SqlDataAdapter("Select * from " + srcTable, staticSQLConn);
SqlCommandBuilder Cb = new SqlCommandBuilder(daAdapter2);
Cb.GetInsertCommand();
retVal = daAdapter2.Update(dt);

}

--
Andrew
"andrewcw" wrote:
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 matches: What dont
I understand here:
( The error I get is : Dynamic SQL generation is not supported against
multiple base tables ). But My DataSet is 1 Table, and my target is 1 table,
Why the error ??
Thanks :
try
{
staticSQLConn.Open();
System.Data.SqlClient.SqlDataAdapter daAdapter = new
SqlDataAdapter(sSQL, staticSQLConn);
daAdapter.AcceptChangesDuringFill = false;
daAdapter.Fill(ds, srcTable); // all entries will be
flagged new

if (ds.HasChanges())
{
rowsToInsert = ds.Tables[srcTable].Rows.Count;
SqlCommandBuilder Cb = new SqlCommandBuilder(daAdapter);
Cb.GetInsertCommand();
DataTable dt = ds.Tables[srcTable];
retVal = daAdapter.Update(dt); // ERROR

}


--
Andrew

May 7 '06 #2

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

Similar topics

4
by: Big D | last post by:
Hi all, I'm trying to understand the best way to use a try catch with a SQL transaction. I have a number of sql statements that need to be run, such as: 'open sqlConnection, get command...
11
by: perspolis | last post by:
hi all When I update my dataset it gives me an error which follows "Concurrecny failed, 0 record affected" I don't know why??..I don't do anything that raise this error.. just when user press...
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
28
by: Siv | last post by:
Hi, If I run the following: strSQL = "Select * FROM Clients;" da = New OleDb.OleDbDataAdapter(strSQL, Conn) 'Create data adapter cb = New OleDb.OleDbCommandBuilder(da) ...
3
by: John Cosmas | last post by:
I have a DATATABLE which I have populated in my application, and I need it written out to a particular table I specify in my ACCESS database. My code works to the point of the MERGE and UPDATE,...
5
by: AAJ | last post by:
Hi all FIRST THE BORING BITS....... I normally use a Database layer, a Business layer and a GUI layer. The GUI uses an Object data source to bind to the Business layer which in turn binds...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: Danny | last post by:
Hi, we just have launched our first beta version of our new product page which was developed with ASP.NET. Now we noticed that we sometimes get the error attached below. After a little web...
6
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.