The full error message is "Dynamic SQL generation for the UpdateCommand is
not supported against a SelectCommand that does not return any key column
information."
I am getting this error when updating a table bound to a datagridview (using
the OLEDataAdapter) when the table does not have a primary key; my code works
when the table does have primary key(s).
Is there a workaround for working with tables that do not have any primary
key(s)?
Thanks for your help. 5 20159
On Jun 12, 9:09 am, AA2e72E <AA2e...@discus sions.microsoft .comwrote:
The full error message is "Dynamic SQL generation for the UpdateCommand is
not supported against a SelectCommand that does not return any key column
information."
I am getting this error when updating a table bound to a datagridview (using
the OLEDataAdapter) when the table does not have a primary key; my code works
when the table does have primary key(s).
Is there a workaround for working with tables that do not have any primary
key(s)?
Any reason you can't manually specify the appropriate update command
yourself?
Jon
Thanks Jon; I did not know that I could and now that you have hinted that it
is possible, I do not know how/where.
Here's my code:
public partial class Form1 : Form
{
static string DBTable = "TABLE1";
OleDbDataAdapte r da = new OleDbDataAdapte r(("SELECT * FROM " +
DBTable), "Provider=Micro soft.JET.OLEDB. 4.0;data source=C:\\db2. MDB");
DataSet ds = new DataSet();
OleDbCommandBui lder builder = new OleDbCommandBui lder();
public Form1()
{
InitializeCompo nent();
}
private void Form1_Load(obje ct sender, EventArgs e)
{
da.Fill(ds, DBTable);
dataGridView1.D ataSource = ds.Tables[DBTable].DefaultView;
}
private void button1_Click(o bject sender, EventArgs e)
{
OleDbCommandBui lder builder = new OleDbCommandBui lder(da);
da.UpdateComman d = builder.GetUpda teCommand();
da.Update(ds.Ta bles[0].Select(null,nu ll,DataViewRowS tate.CurrentRow s));
}
}
The culprint line is
da.UpdateComman d = builder.GetUpda teCommand();
If my table has a primary key, it works fine and fails it it doesn't.
I 'd appreciate some clues. Thanks.
On Jun 12, 10:36 am, AA2e72E <AA2e...@discus sions.microsoft .com>
wrote:
Thanks Jon; I did not know that I could and now that you have hinted that it
is possible, I do not know how/where.
<snip>
The culprint line is
da.UpdateComman d = builder.GetUpda teCommand();
If my table has a primary key, it works fine and fails it it doesn't.
I 'd appreciate some clues. Thanks.
So instead of running that line, run:
da.UpdateComman d = "UPDATE BLAH BLAH";
except using the appropriate SQL.
Jon
Thanks Jon.
Since the table does not have any keys, I can't see how I can use UPDATE; I
can see how I might do it i.e
DELETE FROM TABLE1 // drop all the records
then loop to
INSERT INTO TABLE1 (field list) Values(values)
every row in the datagrid view.
There must be a simpler way, surely!
On Jun 12, 10:58 am, AA2e72E <AA2e...@discus sions.microsoft .com>
wrote:
Since the table does not have any keys, I can't see how I can use UPDATE
Well, that entirely depends on exactly what you want to do. If you
really haven't got any way of identifying the row that you want to
update, then indeed you can't do the update, and you've got bigger
problems than ADO.NET at that point - your table is badly designed.
If, however, there *is* some way of identifying the row, but it hasn't
been set as a primary key (for whatever reason) then you can just use
that.
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mr_burns |
last post by:
Hi there,
How would I check if image generation is supported on my server? I
used phpinfo() but didnt know what to look for.
Also, I just want to resize image when they are uploaded using PHP. Is
this possible? What is the quality like after resize? Cheers
Burnsy
|
by: Martin Mrazek |
last post by:
Hi,
I have a HTML form and need to generate the action-string (what to do
after submission) from values of textfields in the form. It means
something like
<form method="post" action=whatToDo.value>
<input name="whatToDo" value="http:\www.myPage.com\cgi-bin\DoDefault">
....
</form>
|
by: Hugo Ferreira |
last post by:
Hi all,
I'm having a problem here, to which I hope someone to be able to help me :)
I need to apply a XSLT transformation to the output of all my ASPX webpages.
I've recently found the tag <asp:xml> which allows me to point out a
transformation document, and put inline XML. The problem is: I cannot mix
logic in this XML. A simple example:
<asp:xml TransformSource="XslDemo.xslt" runat="server">
|
by: Markus Broy |
last post by:
Hello everybody,
I have a problem concerning the dynamic creation of a CustomValidator.
If I create a CustomControl as shown in the code below and the page is post
back the validation procedure is never called.
In Page_Load Page Validate() is called and in the control which should be
validated there is a non numeric value.
|
by: abroc |
last post by:
sir,
i due course of my project i have come up with the need of dynamically
generating my crystal report as the input to the report is the
datatabale which is dynamic by nature and is constructed on the fly
when user make selection in a list box. The number of selection he
makes and the type of selection he makes define the structure of my
table at run time. i have been able to construct the ddata table but
now how to feed this table into...
| |
by: Thomas Qvist |
last post by:
We are building a suite of programs consisting of both winforms applications
and
office addins.
We would like to pre-generate the xml-serialization classes and add it to
our project to
avoid the overhead at startup and thus enhance the performance of our
applications.
The programs are coded in c# under .net 1.1.
|
by: fedya |
last post by:
I am trying to have the last 12 months to always be the option in the dropdown for a combo box. (Basically a combobox, with dynamic options)
I am using Access 2000.
What is the function and syntax in visual basic to edit a combobox? I can do all the dynamic month generation, but I do not know how to edit a combobox from VB.
Thank you.
|
by: Jawad Rehman |
last post by:
Hello everybody.....
I have an excel file which is resided on server,there is some data on
the cells .Now i want to
generate dynamic graph on the basis of the data present in the excel
file using ASP.NET.
I have solution of this ,that i should use the Com component
interop.microsoft.excel.but
According to the specifaction of this Com Component.In order to
|
by: Jawad Rehman |
last post by:
Hello everybody.....
I have an excel file which is resided on server,there is some data on
the cells .Now i want to
generate dynamic graph on the basis of the data present in the excel
file using ASP.NET.
I have solution of this ,that i should use the Com component
interop.microsoft.excel.but
|
by: Samishii23 |
last post by:
By generator I mean, like MakeForm('Form1'); pushes out a user password form. Then MakeForm('Form2'); make form that adds Car data information into a DB?
That kind of thing.
I was originally thinking about a "String" parser like this: "fName=Name|fType=Text|fSize=13|fMaxLen=25|". Would print out a <input> tag with the above listed parameters.
Anyone have a thought on this?
Cause my project is gonna have atleast 20 forms or more. And...
|
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,...
| |
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: 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...
|
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: 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();...
|
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...
| |