|
Hi,
I am writing a program with a database ( xxxx.mdb), and the data set is displayed on a DataGrid.
I've implemented an Add function to add new record and it's ok.
But I can't delete an existing record. The following code is what I've used.
this.BindingContext[dbProductSet1, "Products"].RemoveAt(this.BindingContext[dbProductSet1, "Products"].Position);
It runs ok, but the record can't be deleted. And, when I later execute:
oleDbDataAdapter1.Update(dbProductSet1);
An error occurs saying: "Update requires a valid DeleteCommand when passed DataRow collection with deleted rows."
Afterward, I added this line and tried again:
dbProductSet1.Products.AcceptChanges();
The error message is gone and it seems ok, but in fact the "deleted" record isn't deleted!!
Can anyone please give me comments?? Thank you!!!
|
|
|
|
|
Once you do DataSet.AcceptChanges() or DataTable.AcceptChanges(), a DataAdapter no longer sees your changes and therefore doesn't call the required command. DataAdapter() uses DataSet or DataTable.GetChanges() to get a DataSet or DataTable with just the changes and it knows (based on state) which rows have been deleted, inserted, or updated. So, as the error states, you need to assign an OleDbCommand to the DeleteCommand property of the OleDbDataAdapter. That way, when it runs across a record that has been marked for deletion, it'll call the appropriate SQL statement to delete the record.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
how can i hide the console in my exe program until i call apon it too be opened (in this case a -console commandline paremeter)
jesse m
|
|
|
|
|
Just shooting from the hip here.
If there isn't any solution buried in the MSDN docs, or some bizarre method lurking on some System object, why not make your program a WinForm that hosts your program and mimics a console instead. That would give you a *much* higher degree of control than you would need (room to grow even).
If you absolutely need to use the Console.Readline/Writeline for i/o, I suppose you could try "hijacking" the streams already supplied by the class for display. The Console class supplies methods for opening and setting the Input/Output streams and TextReaders (respectively).
.. anyway, give it a shot, and good luck.
- Eric
Calling a function is like tying your shoe. Remoting a function is like tying someone else's shoe... while they're running around... in China.
|
|
|
|
|
yeah i think ill just make my own kinda console on a seperate class / dll (ill have more room to grow and do other stuff with it like you said..besides games like tfc definitly dont use a standard C++ console lol)
thanks alot eric for the info..
|
|
|
|
|
How do you cast the object ? I keep getting the error "Can't implicitly cast ..."
ResultClass 1Result = new ResultClass()<br />
<br />
IEnumerate resultsEnum;<br />
resultsEnum = Results.GetEnumerator();<br />
<br />
while(resultsEnum.moveNext()){<br />
1Result = (ResultClass)resultsEnum.Current<br />
<br />
}<br />
I have a class full of results (Lets call it results) and each index contains a result object(or 1 result).
Problem is when I enumerate the class "results" I can't cast into the 1Result class .. Anyone ?
Ex.
By the way the references are COM objects and the 1Result is a variant.
Thks in advance !!!
|
|
|
|
|
First you can't / shouldn't start variables with a number. Second, GetEnumerator() returns an IEnumerator, not IEnumerate. That's why it can't cast. Your last line of code is correct.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
I am facing some difficulties with the licensing scheme in .NET.
I have created a solution with 2 projects:
- a licensed windows form .NET control (written in C#)
- a small application hosting the control (written in VB)
Currently, I just try a basic licensing using the .NET LicFileLicenseProvider.
I am quite sure to have written the code as indicated in the .NET doc.
However it does not work. The license exception is raised except is the license file is placed in the application exe directory. It seems that no license key has been embed in the .exe.
Does anybody has faced such a problem? How to solve it? (I use .NET v1)
|
|
|
|
|
yes i had the same problem first.
but i think it will be solved if you simply compile your control first (in a separate solution)
then open your host app .
add the control to the toolbox , and place it on a form in the host app.
(your license file should be located in the same dir as the .dll)
now vs.net should generate a "licenses.licx" in your host app..
(you will only see this if you show all files in the project explorer)
if you open the "licenses.licx" it should contain something like:
"MyControlProject.MyControl is a licensed component"
and the "licenses.licx" should be an "embeded resource".
if all this apply , your licensing should work...
//Roger
|
|
|
|
|
Thanks very much.
I have followed your advices and have finally been able to solve my problem!
|
|
|
|
|
Something else to think about:
Since you are licensing your controls I assume that you probably
want to keep people from recreating your "source" code via the .NET
disassemblers/decompilers that are already out there.
For a scary example of one see: http://remotesoft.com/salamander/index.html
(You can test their disassembler on your own code on this site)
This tool will recreate your original source code minus some comments.
I have a question: Has anybody found a way (e.g., a build flag)
to make decompiling of .NET assemblies more difficult besides paying
a $1K for an MSIL obfuscator?
TonyJ
|
|
|
|
|
I have purchased an obfuscator (from Preemptive Solutions).
|
|
|
|
|
I'm hoping not to pay twice for something:
#1, Pay MS so I can COMPILE programs/libraries
#2, Pay someother company so $$ so someone else can't DECOMPILE
the code I COMPILED
Thanks anyhow. I'll take a look at the company if I can't find a
free alternative.
|
|
|
|
|
Ok, here's the deal - I have two assemblies in a project along with a tester application. The tester application is dependant on (and references) both assemblies, but neither of the assemblies reference each other. I have set up the dependancies and references for the tester app in VS.NET (including setting the references to the assemblies to copy the referenced assemblies local). When i launch the tester application, i get a IO SystemException saying that one of the dll's or its dependancies can't be found, yet if i open explorer and look in the bin\debug folder, i can see both of the assembly dll's along with the tester executable.
Any help? This is very frustrating.
Thanks!
|
|
|
|
|
the_grip wrote:
When i launch the tester application, i get a IO SystemException saying that one of the dll's or its dependancies can't be found, yet if i open explorer and look in the bin\debug folder, i can see both of the assembly dll's along with the tester executable.
One or both of the assemblies probably has a dependancy on another assembly that is not in the progrm directory or the GAC.
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
That's what i initially thought, however, they only reference the base assemblies (System, etc.). There are no custom references defined that these are dependant on. Surely I don't have to copy these dlls... that should be in the environment path... or do i need to set these to copy local?
i should note that i had this problem once before... i had to strong name my assemblies and add them to the GAC before it would work. This was a few weeks ago, and i dumped that solution. Every time i rebuilt the assemblies i would have to reregister them in the GAC. Surely there is a better solution (i can't imagine having to do this just to test assemblies)?
|
|
|
|
|
Weird. I would suggest using Reflector .NET , it will popup a dialog for the needed assemblies when laoding an assembly. http://www.aisto.com/roeder/dotnet[^]
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
Thx leppie... i downloaded all those proggies off that page... good stuff.
i DID manage to finally find my problem. i was referencing the debug dll's for the assemblies (wrong), co i changed it to reference the assembly projects (right). i could have used the release dll's i guess, but this way solved my problem.
Oh well - there's another hour or two down the tubes on stupid troubleshooting errors Thanks again for the help.
|
|
|
|
|
the_grip wrote:
Oh well - there's another hour or two down the tubes on stupid troubleshooting errors
I had a problem the other day, that each time i was compiling an assembly it was adding a reference to a then removed reference , eventually 20000 builds later it leaved me alone.
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
Can anyone point me in the direction of an article that explains the differences between release mode and debug mode in VS.NET?
Thanks in advance
Andy
|
|
|
|
|
The Debug configuration of your program is compiled with full symbolic debug information in Microsoft format and no optimization (optimization complicates debugging, since the relationship between source code and generated instructions is more complex).
The Release configuration of your program is fully optimized and contains no symbolic debug information. Debug information may be generated in separate PDB files.
Debug mode: produces .pdb file and a larger footprint for debugging purposes.
http://msdn.microsoft.com/library/en-us/cscomp/html/vcrefDEmitDebuggingInformation.asp[^]
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
Debug modes also generate IL when using the System.Diagnostics.Debug class, such as Debug.WriteLine (just like Trace except only applies in Debug modes). When you compile without DEBUG set (i.e., release builds), the compiler ignores these statements. This way, you don't have to worry about a lot of preprocessor conditions or finding all the tracing in your code. Leave it - it won't be compiled when you release.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Hi,
Im still quite new i the c# world.
My question is how to have a struct containing a pointer.
eg.:
For example. if I have a unsafe class containing
public struct Node
{
public int Value;
public Node* Left;
public Node* Right;
}
And add a node
public void add(int val)
{
Node n2 = new Node();
n.Right = &n2;
n2.Value = val;
n2.Right = null;
n2.Left= null;
}
And at last get it eg:
public void get()
Node l = *n.Right;
System.Windows.Forms.MessageBox.Show(l.Value.ToString());
How can I "pin" it so the garbege collector isn't moving it?
regards
|
|
|
|
|
since its unsafe code you can use the fixed keyword
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
As I understand the fixed statement only pins the pointer only in tha fixed statement and not ouside.. So I cant find a solution to the above, cause then it only works in that only method?
|
|
|
|