|
hi, I have a dataset, DataSet1, populated from a database table named "Sections" which is bounded to DataGrid1.
I want to remove a row if a user selects it in the datagrid and presses the remove button. here is the vb-code (I actually have my code in VB, but as you know, there is no difference:
Private Sub cmdRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemove.Click
If DataGrid1.CurrentRowIndex >= 0 Then
DataSet1.Tables("Sections").Rows.Remove(DataSet1.Tables("Sections").Rows(DataGrid1.CurrentRowIndex))
MessageBox.Show(DataSet1.HasChanges)
OleDbDataAdapterSections.Update(DataSet1, "Sections")
DataSet1.AcceptChanges()
End If
End Sub
But messagebox shows False, and the row is not actually removed from the database, ALTHOUGH DataGrid1 shows that the row has removed from dataset!
(I use the same method i.e. DataSet1...Rows.Add(..) and then the oleDbDataAdapterSections.Update(..) to add rows which works perfectly!! But the added rows are not removed using the same code from the database...)
I really dunno the reason and got confused!
-- modified at 17:50 Friday 31st March, 2006
|
|
|
|
|
Instead of removing the row from the rows collection, call the Delete method of the Row. Calling the delete method of the DataRow will change the state of the row to deleted and haschanges should become true. Once you call AcceptChanges on the dataset or datatable the deleted row will automatically be removed from the rows collection.
|
|
|
|
|
Thank you jimbo! I really owe you...
I really had stuck in this..
But in this case, can we conclude that Rows.Remove only removes the row from the Rows collection in the dataset?
I mean I still cannot understand why Remove didn't work?
Thank you again.;)
|
|
|
|
|
yes Rows.Remove removes the row from the rowcollection, but haschanges won't be able to detect that the row has been deleted and so it returns false. You see, haschanges examines the row collection and if any of the rows are modified, inserted or deleted it returns true, otherwise false. If you just remove the row it doesn't appear in the rowcollection as a deleted row (it simply disappears) and so haschanges will not detect that any changes have been made. On the other hand, when you call delete, the state of the row is set to deleted, and thus haschanges will return true.
|
|
|
|
|
Once again thank you for your comprehensive description. Now I totally understand what happens and my vision on this really expanded...
|
|
|
|
|
hi i want to creat a find tool on my text editor
thank u
abdelhameed81
|
|
|
|
|
Short summary: I've been trying to extend a PDF-writing utility I found here on codeproject.com to create PDFs that display jpegs, text, and tables. Thus far, I've been able to write a file that Adobe Acrobat opens, displays text and tables, and does not generate image data error messages.
Here's the problem:
Adobe Acrobat will not display the image.
When I open a similar -- functioning -- PDF file in notepad, and compare it with my generated file, the contents of both files APPEAR to be virtually identical. At least, in all ways that should matter. Nonetheless, the image does not display.
Does anyone out there have experience with generating PDFs using C#? I can supply applicable code snippets as needed, or take this conversation to IM/email/etc.
Any suggestions would be appreciated!
Alice (The novice C#/Java programmer)
|
|
|
|
|
Lots of possibilities here. What version of Acrobat? What version # is the PDF you're writing? Is the image large and do you have the preference to suppress the display of large images on? Is the matrix setting up the display of the image correctly? What kind of filter is on the image data? These are some of the obvious things which could be wrong.
Mark
|
|
|
|
|
1. Acrobat Reader 5.1
2. Both files start off:
%PDF-1.4
%
3. The image may be large, but it is the exact same image in both files. File 1 -- generated by Pdfizer -- encodes the exact same jpeg that File 2 -- generated by my extension of PdfLibrary -- uses. File size: 3.04 kb
Not sure what you meant by having the preference to supress the display of large images.
4. As far as I know, the matrices are the same in both files.
5. DCTDecode? I put a question mark because I modelled my file after the working file. I'm not sure if this is the filter to which you are referring.
XObject from the working file (image data snipped):
4 0 obj
<</Width 192
/BitsPerComponent 8
/Name /img0
/Subtype /Image
/Height 39
/Filter /DCTDecode
/Length 3123
/ColorSpace /DeviceRGB
/Type /XObject
>>
stream
ÿØÿà JFIF ` a ÿÛ C
...
dà~µÝQEy•ˆÎê?ÿÙ
endstream
endobj
XObject from my file (image data snipped):
7 0 obj<</Type/XObject/Width 192/BitsPerComponent 8/Name/img7/Subtype/Image/Height 39/Filter/DCTDecode/Length 3123/ColorSpace/DeviceRGB>>stream
ÿØÿà JFIF ` a ÿÛ C
...
dà~µÝQEy•ˆÎê?ÿÙ
endstream
endobj
First one references img0 at 4 0 R in the page object.
Second one references img7 at 7 0 R in the page object.
Turns out the media box does not match
file 1: MediaBox [0 0 595 842]
file 2: MediaBox [0 0 612 792]
but I have trouble believing that this, alone, would keep the image from displaying.
Alice
|
|
|
|
|
Looks like the image data is the same in both object 4 and 7. The different sized MediaBoxes might cause clipping, but should stop the display of the image. What does the call to the Do operator look like?
Mark
|
|
|
|
|
I have tried to put my C# applications and DLLs developed with VS.2005, including some C# DLLs that wrap legacy C++ DLLs (via Managed C++), on a computer that has no development environment. I thought if that computer had .NET 2.0 (and I am using some .NET 2.0-only components), my applications would run. They do not. They run fine on my development machine, but when I run the exact same executables on the exact same USB drive on another machine, they either fail to load (FileNotFoundException, but of course it doesn't tell you what file was not found), or they load but fail to work (unable to create TCPListener socket). Since there is no difference in the bits or in the directory, that leaves the path, as far as I can think. But apart from the VS.2005 development directories, the only path differences are to windows or winnt's system32 directory.
So what does one need on a Windows 2000 or XP machine, both of which have ALL service packs and updates and both of which have just had .NET 2.0 installed on them, to get programs to run properly? Any help would be greatly appreciated.
I have NOT made a deployment project of any kind and don't see why I should have to. I have just move the bits, including all dependencies from one machine to another.
|
|
|
|
|
BambooMoon wrote: legacy C++ DLLs (via Managed C++)
I think this is your problem
Do you have all the files required to run these?
Ed
|
|
|
|
|
|
Ah well, I'm not a C++ guru so there
Ed
|
|
|
|
|
i declared a word file and tried to include a picture inside it...but i couldn't!!!
Can i find any help???!
|
|
|
|
|
Why does this not work.. im sure the syntax isnt right, but what should it be.. im trying to refference text boxes in a form...
this.tblInvoiceTableAdapter.UpdateQuery(owner_NameTextBox,owner_AddressTextBox,owner_CityTextBox,owner_StateTextBox,owner_ZipTextBox);
the error is simply "Error 2 Argument '1': cannot convert from 'System.Windows.Forms.TextBox' to 'string' "
I have tried the ".tostring" thing, no luck.
Sorry for the stupid question, im just starting out.
|
|
|
|
|
You need to reference the .text property.
I.e.
this.testBox1.text = "some string"
In your case it would be...
this.tblInvoiceTableAdapter.UpdateQuery(owner_NameTextBox.Text,owner_AddressTextBox.Text,owner_CityTextBox.Text,owner_StateTextBox.Text,owner_ZipTextBox.Text);
|
|
|
|
|
|
Ok so I created a COM object in C#. It's a class library project with "Register for COM interop" turned on. Fine. Once built how do I register this module on another computer? Regsvr32 says it doesn't have DLLRegserver etc. entry points and regasm says the module is not a valid assembly. So what should I to register it. MSDN article "How to: Register a Component for COM Interop." just desribes hot to turn that "Register for COM interop" option for project. Doesn't say a word on doing it manually on another computer.
Thanks a lot in advance!
|
|
|
|
|
Hi,
I put a timer control in a form. I start it (tm.enabled=true) at the contstructor. It works well. but later on, I use the code like this:
tm.Interval=2000; //(different value)
tm.Start();
But the timer stop ticking???
Why???
I have to change the interval dynamically. please help me!!
Thanks!!!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
|
thx,
I solve the problem by using System.Timers.Timer instead of System.Windows.form.Timer.
I have no time to find out what is the difference between them .
but I think it should not happen.
thx again!!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
|
i have recently noticed that when i minimise my windows app the amount of memory task manager says its using goes down drastically
approximately beginning at 12mb when the program is and reducing to 2mb when i mimimise it, when i put it back to the normal window state it increases to 4mb but never back to the 12mb. i'm assuming this is something windows does for efficency.
so the question is, is there any way to replicate this through C# code and reduce the memory my program uses without waiting for someone to minimise it?
thanks for any advice u can give
-- modified at 13:47 Friday 31st March, 2006
|
|
|
|
|
Why would you want to?
It gives your app less room to 'move' and you will feel a reasonable performance hit if you do - due to the program having to ask for more memory when it needs it, rather than using its reserve. Appart from the nice warm fuzzy feeling you get when you see the smaller memory usage in Task Manager, this serves no purpose. The usage shown by task manager is merely the applications working set, not its actual memory consumption.
You can, however, do this in C# like so...
System.Diagnostics.Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
currentProcess.MinWorkingSet = currentProcess.MinWorkingSet; (that code comes from here[^])
Cheers,
Will H
|
|
|
|