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.O pen();
System.Data.Sql Client.SqlDataA dapter daAdapter = new
SqlDataAdapter( sSQL, staticSQLConn);
daAdapter.Accep tChangesDuringF ill = false;
daAdapter.Fill( ds, srcTable); // all entries will be
flagged new
if (ds.HasChanges( ))
{
rowsToInsert = ds.Tables[srcTable].Rows.Count;
SqlCommandBuild er Cb = new SqlCommandBuild er(daAdapter);
Cb.GetInsertCom mand();
DataTable dt = ds.Tables[srcTable];
retVal = daAdapter.Updat e(dt); // ERROR
}
--
Andrew 1 2080
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.Dispo se();
System.Data.Sql Client.SqlDataA dapter daAdapter2 = new
SqlDataAdapter( "Select * from " + srcTable, staticSQLConn);
SqlCommandBuild er Cb = new SqlCommandBuild er(daAdapter2);
Cb.GetInsertCom mand();
retVal = daAdapter2.Upda te(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.O pen(); System.Data.Sql Client.SqlDataA dapter daAdapter = new SqlDataAdapter( sSQL, staticSQLConn); daAdapter.Accep tChangesDuringF ill = false; daAdapter.Fill( ds, srcTable); // all entries will be flagged new
if (ds.HasChanges( )) { rowsToInsert = ds.Tables[srcTable].Rows.Count; SqlCommandBuild er Cb = new SqlCommandBuild er(daAdapter); Cb.GetInsertCom mand(); DataTable dt = ds.Tables[srcTable]; retVal = daAdapter.Updat e(dt); // ERROR
}
-- Andrew This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 object, etc.
myTrans.BeginTransaction()
'do a delete
'do a update
|
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 Save button I call Update mehtod of my SqlDataAdaptor..
|
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 a
DataGrid, and set the PrimaryKey of the DataTable to be the first cell
in the grid (which is a UserID value). I then store the DataTable in
a session object, from which it is retrieved for subsequent pages.
All this seems to be working fine.
...
|
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) 'Create command builder using the datadapter
dt = New Data.DataTable
da.Fill(dt) 'pour in the data using the adapter
|
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, but it creates exactly the
number of BLANK records per the populated DATATABLE. Here is my code...
pstrDestinationTable = "tws_tbl_Case_Scanner_" &
GetDateTimeStamp()
pstrSQL = "SELECT * INTO " & pstrDestinationTable & " FROM...
| |
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 to the database layer. Every thing is great. I can read data,
change data in the grid, update the database, and when the GUI reloads, all
the changes are all present and correct. i.e. the data seems to be persisted
|
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
********************************************************
For this teeny job, please refer to:
http://feeds.reddit.com/feed/8fu/?o=25
|
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 research, we then could find out, it's a bug of the
latest .NET framework and that there is a hotfix out
(http://support.microsoft.com/?scid=kb%3Ben-us%3B932491&x=15&y=13).
|
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 clsStat.vb.
Then I pass this class to a thread.
Each thread will call a function inside the clsStat.vb to do a "Select" of
the datatable.
Every day around the same time this function that does the select of the
databale gets errors like so:...
|
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...
|
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...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |