|
Hi Chris!
I'm pretty sure that Managed DirectX is not installed out of the box, so I'd try installing it first.
Regards,
mav
|
|
|
|
|
I'm sure you're right, but as it's the latest version in SP2, trying to install over the top is not possible.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Good evening ( although it's night time in Sweden)
I'm trying to delete all my records in a single table with a DataAdapter. The code I use is this:
odbAdapter = new OleDbDataAdapter();<br />
odbAdapter.SelectCommand = new OleDbCommand("Select * from Bilder", odbConnection);<br />
OleDbCommandBuilder cb = new OleDbCommandBuilder(odbAdapter);<br />
<br />
odbConnection.Open();<br />
odbAdapter.Fill(ds, "Bilder");<br />
<br />
DataTable dt = ds.Tables["Bilder"];<br />
<br />
DataRow[] dr = dt.Select();<br />
<br />
foreach(DataRow item in dr)<br />
{<br />
item.Delete();<br />
}<br />
<br />
odbAdapter.DeleteCommand = cb.GetDeleteCommand();<br />
odbAdapter.Update(ds,"Bilder");<br />
However, I get an error message saying :
Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information
I'm guessing this has something to do with a primary key or something, judging by info gathered at other places. The primary key in the table is not automatically generated or anything. What the heck am i doing wrong here?
|
|
|
|
|
Why are you using a DataAdapter for this? If all you want to do is delete all the records in a table, why have the database waste the time retrieving them all and send them to you, just so you can tag them all for delete (one at a time, very time consuming!), then have the Adapter run a delete command on them (one at a time again!)?
Just tell the database to delete them all yourself!
string sql = "DELETE Bilder";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand comm = new OleDbCommand(sql, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 21:55 Thursday 22nd December, 2005
|
|
|
|
|
Stefan R wrote: Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information
Since your SELECT command is returning all the columns of the Bilder table, this message means that your table doesn't have a Primary Key. DataAdapters will only work with tables that define a Primary Key.
This is because changes that are made you the DataSet are written back to the database one record at a time. The DataAdapter looks at each record in the DataSet and determines which SQL Command to execute against that record in order to properly update the database, wheather it be an INSERT, UPDATE, or DELETE command.
Now, if the DataAdapter is making changes to the tables in the DataSet one record at a time, how does it know how to tell the database which record to change? This is what the Primary KLey in each table is for. Without it, the DataAdapter has no consistant way of uniquely identifying every record in each tabel in the dataset.
For example, when you delete a record out of the DataSet, the DataAdapter executes a SQL DELETE command against that record. That command will look something like this:
DELETE FROM tableName WHERE PriKeyColumnName = DataSetPriKeyValue
This DELETE command is generated by the CommandBuilder object you created. It looks at the SELECT statement and the returned DataSet and uses the information in that set to generate the respective UPDATE, INSERT, and DELETE SQL statements, each with a WHERE clause that identifies which record in the database to execute the statement against.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know i can easily delete all records with "delete from biler" and i know the problem is not related to my SQL-statements or db schema. I'm just new to working with the DataSet. Since i want to learn how to work with the dataset i want to avoid using the method above. I want to be able to remove records one by one in the future...
The table has a primary key defined in my Access db, however it seems that the DataAdapter doesn't retrieve any meta data about primary keys and constraints from the table( as stated in msdn ). That's probably way the message says that i don't have a primary key. MSDN also states that i should specify which column is the key column somewhere in code and i have read something about MissingSchemaAction.AddWithKey ...
The problem is that i can't seem to get it right. How do i make the DataAdapter fetch information about the primary key? Or how do i tell the DataAdapter that a certain column in the fetched table is actually a primary key column? This is really bugging me out
-- modified at 4:59 Friday 23rd December, 2005
|
|
|
|
|
There's go to be something wrong with your table then. There's no problem with using a DataAdapter with an Access table.
If your table is correct, then you really don't have a need to specify which column is the PK. I've never run into the problem. This code works just fine:
[EDIT]Sorry, wrong language for the forum...[/EDIT]
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\TestBlank.mdb";
string sql = "SELECT * From MyTable";
OleDbDataAdapter da = new OleDbDataAdapter(sql, connString);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds, "MyTable");
foreach (DataRow row in ds.Tables("MyTable").Rows)
{
Debug.WriteLine("ID: " + row("TestID"));
row.Delete();
}
da.DeleteCommand = cb.GetDeleteCommand();
da.Update(ds, "MyTable");
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 10:25 Friday 23rd December, 2005
|
|
|
|
|
I tried changing primary key data type from "PM" to "Text" in the db and now it works just fine. I really did have a primary key though , and after reading that thing about "...OleDbDataAdapter not fetching primary key constraints..." on MSDN i really thought i was in trouble.
But as always, the problem lies in something small and unsignificant to the eye
Dave Kreskowiak wrote: [EDIT]Sorry, wrong language for the forum...[/EDIT]
I'm pretty fluent in VB syntax so i don't mind
Thanks a lot for the help!
|
|
|
|
|
Stefan R wrote: I'm pretty fluent in VB syntax so i don't mind
Yeah, I changed the code becauseif you're caught posting VB code in the C# Forum, ... well, let's just say it makes the movie "Desparado" look like a Sunday Brunch.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
if i create a webbrowser object, and there is a form (with name="something") on the page displayed, is there a way i can automatically submit it using c#?
thanks in advance,
sam kline
<a href="http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450">YES</a>
|
|
|
|
|
Hi, Does anyone know a good way to make reports in c#? not in Crystal Reports(Money issue) ..
i'm lookin for a simple report, maybe something thats like access reports.. ..
any idea will do ..
thanks in advance ,.. Yosi.
|
|
|
|
|
There is at least one free library that draws graphs, you could use that to create your own report, I guess. You'd have the data you need from your data source already.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I recently made reports using the GDI, PrintDocument and PrintPreview controls of .NET. Although its a lot of boring work when you use GDI to draw lines and such but I did it.
Bikash Rai
|
|
|
|
|
Is there anychance you can post me the code?
i'm in a mess... i got this presentation on sunday, and i was counting on that crystal reports, but then i found out it need to be registerd...
anyhow,, if you could post me the code , i will the most grateful man on eatrh!
|
|
|
|
|
I have sent you the code as a Zip attachment. Although the code is in VB.NET I think you won;t have any problems porting it to C#. I couldn't post the code here because the code's long...... really long.....
Happy Printing...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
http://www.codeproject.com/csharp/letaonarticle2.asp
|
|
|
|
|
The code are looks like this:
Panel panel1 = new Panel();
if(panel1.CanFocus){
panel1.Focus();
}
Then it generated a exception at the run-time.
An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
Additional information: Collection was modified; enumeration operation may not execute.
Focus() has nothing to do with the collection, is that because of UIPermission fails?
Thanks
|
|
|
|
|
Perhaps a handle of panel1 fires a method that generates that exception or that prepare the field for the exception.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
You're getting this error because a Panel control cannot receive the input focus. See Control.Focus()[^] for a list of controls that cannot be .Focus ed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks a lot. I will try to not use focus() in my code.
In fact, my problem is as this:
if(A.Focused){
B.Focus();
A.Focus(); //get an exception in main()
}
The reason for reset A's focus is that I want to clear A's keyboard input buffer. Otherwise the A's keyboard input will always be put into the next selected item.
I guess it is a bug in .net library and it can not be fixed without the source code.
Thanks again.
Merry Christmas to everybody
|
|
|
|
|
This won't clear the keyboard buffer. Once the keystrokes are sent the that window, that's it. That window has to process them.
BTW: This is NOT a bug in the .NET Framework. This is the documented behavior of the control! The bug is in the design of your code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, someone knows what kind of component/widget/technique is needed to emulate the MSN (7.5) Options window behavior?
I mean, when you click any option in the listBox on the left, the groupBox of the right changes accordingly (with different set of options for each selected item).
I want to do a Configuration dialog like that and it seems not so obvious for me to figure out the best or smart way to do that.
Thanks in advance
Zopiro
|
|
|
|
|
How to break long line of code into several lines of short codes like what one can do in C++?
Thanks!
Devin
|
|
|
|
|
int my_very_long_variable_name = My_Very_Long_Method_Name(my_first_argument, my_second_argument, my_third_and_longest_argument, "some very long long string....");
Can be writen as well as
int my_very_long_variable_name = My_Very_Long_Method_Name(
my_first_argument,
my_second_argument,
my_third_and_longest_argument,
"some very long"+
" long string...."
);
btw, if you have a very long math expession, uualy is more useful to write it step by step (aoiding bugs is a must)
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|