|
The database will not be updated because you call AcceptChanges() before DataAdapter.Update(). After you called AcceptChanges() the RowState for all Rows is "UnChanged". Then you call the DataAdapter.Update() but the Update Method cannot find any Rows which are marked as "Modified", so the DataAdapter doesn't update any rows.
Just call DataAdapter.Update() without AcceptChanges() before and the table will be updated in the database too.
I had the same problem as I started with C# and databases. The microsoft help is also confusing because everywhere is written to use AcceptChanges() to update a datatable.
Hope this helps.
Stefan
|
|
|
|
|
Can anyone help me to realyse ssh2 on c#?
Any links?
Thanks
=====================
http://wasp.elcat.kg
|
|
|
|
|
|
i created a table with 9 columns using datatable and tablestyles.
Also i got a DataRelation.
How can i tell my childcolumn to change if the parentcolumn changes?
e.g. in column "number" is 10 the value,
if value changes to 17 in parenttable,change it also in childttable
Thanx
|
|
|
|
|
Help!
In C# how can I create a few views and according to the view selected from a menu change the view being displayed on the main frame??
Also is it posible to create the different views using the designer?? or doing this will create different frames instead?
Sorry this is for a windows application
|
|
|
|
|
|
In C you could have multiple threads simultaneously writing to the same array but different array indexes without worrying about race conditions.
Can I do the same thing in C#?
I ask because an array in C# is more than just a chunk of memory. Do I need to lock the entire array before I write to a single element even if I know that each thread will be writing to a different index?
|
|
|
|
|
AFAI understand it, you need to create a syncronized version of the collection/set , that would allow many threads to read, but only one to write.
I dont think u need to lock the entire array though, isnt it just possible to lock the element?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
You're probably best off working with a collection, as .NET collections have built-in synchronization features. Look it up on MSDN.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
|
albean wrote:
I ask because an array in C# is more than just a chunk of memory.
Not exactly. One-dimension arrays in C# are actually objects that store a pointer to a C-style array, so what you are asking is actually safe on C#, if your algorithm is really thread safe.
ORACLE One Real A$#h%le Called Lary Ellison
|
|
|
|
|
Excellent explanation! Thanks Daniel.
|
|
|
|
|
but anyways... when I run it, it only displays the last file in the folder, according to alpabetical order... so if there are 3 folders: Alex Ben & Carly.... only the highest letter will show up... Carly...
it does this in every folder.... what's wrong?
here's my full code...
private void Page_Load(object sender, System.EventArgs e)
{
DirectoryInfo di = new DirectoryInfo("C:\\program files\\");
DirectoryInfo[] diArr = di.GetDirectories();
foreach (DirectoryInfo dri in diArr)
{
labelPath.Text=dri.Name;
}
}
/\ |_ E X E GG
|
|
|
|
|
It depends on what "labelPath" is. If it is simply a label you are repeatedly assigning it a version which overrights the previous one. Have you stepped through the code in the debugger? I would assume it is running the foreach three times (in your example of data), but you only pick up the last because it was the last assigned.
You could use a StringBuilder class and combine the names adding a line break to to each line. Depends on where the output is supposed to go.
Rocky Moore <><
|
|
|
|
|
eggie5 wrote:
labelPath.Text=dri.Name;
should be
labelPath.Text += dri.Name; , as Rocky pointed out you are just reassigning the name to the text each time through the loop. Instead you want to append the name to the text each time through the loop.
You may also want to add in some <br /> elements so that you get them on each line as you asked in your reply to me before (CP was giving me Error 500 fits )
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
I am searching for a .NET MIME encoder/decoder library. Please let me know if you know of one.
Thx
|
|
|
|
|
|
I am using SQLDMO to build a code generation application. When I find a column type in a given table, it usually comes back with the name 'int' for an integer, 'varchar' for a VarChar etc. The problem is that I need to do a translation from that sql type to the approrpriate SqlDbType in C# (e.g. SqlDbType.Int, SqlDbType.VarChar), so that I can output some source code that will build with no further modification. I, obviously, could just ignore the case difference and make the change manually to the generated code, but it seems there should be a way to avoid this.
Now, of course, I could create my own hashtable and hard code the mapped values (e.g. 'int' -> 'Int', 'varchar' -> 'VarChar', etc.), but it occured to me that this may already be in either the framework or the SQLDMO. Is anyone aware of a way to make this translation using a built-in mechanism? Or am I stuck creating a hard-coded map?
TIA.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
If all the values match, except for case then you could try using Enum.Parse() to get the correct enum value and then outputting the name into the code you are generating.
|
|
|
|
|
Very nice!! Thank you. That seems to work. I haven't tried all of the data types yet, but it looks pretty good.
Thanks again.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I'm fairly new to the C# environment but coming from Delphi, most of what we've been doing has been very familiar. Primarily, the difference has been syntax and a few new features we didn't have. An important technique we used a lot was the reusing of forms. This was done by creating a form, such as an address form, and reuse it in several areas. The exact same form would be used in the maintenance of people, shipping, billing, etc. while and underlying class property dictated the rules of the form.
Why do this? The flexibility and look of MDI was not nearly what we desired or needed. Instead, we created a form with panels in it. We then positioned the panels where we wanted them. We could then take a completed form (whose parent is SELF by default) and set the parent property to the panel. The second line of code set the form's alignment to client. This essentially pasted the form into the panel. This gave us the ability to have a developer build the central application while other tasks were divided by specialty. Now, if I were putting together something that needed the module that needed an address, I'd put a panel in the main application and just paste the address form into the panel at run time. I'd them use the class methods and procedures to move information appropriately.
What I'd like to do is perform this same type of task in C#. I've tried a few things but I'm not getting past the fact that a form is a "top level control". The impression I get is C# treats controls in a heirarchal form and a panel is lower than a form. Once the form is identified as such, I'm not allowed to put the form into a "lower" type control.
Are there any suggestions for doing something similar to this? This is quite a powerful technique that can be utilized even better in C# than in Delphi because of the ability to build multiple interfaces (shipping address maintenance, billing address maintenance, personal address maintenance, etc) and utilize them as the task requires.
|
|
|
|
|
make these "forms" as usercontrols instead.
|
|
|
|
|
An instance of MyClass is running in Thread A. This instance of MyClass instantiates an instance of YourClass.
As part of the constructor of YourClass a worker thread (Thread B) is started. When this worker is completed it calls a delegate callback function in MyClass.
In which thread context is the delegate function executed? Thread A or B?
|
|
|
|
|
I think that any function called from a delegate will normally be executed on a thread from the thread pool. Thus it will not be executed on Thread A or Thread B.
I have some memory of a way of getting a delegate to execute on a particular thread, but can't recall the details right now.
|
|
|
|
|
Hi all,
I've been trying to subscribe to SourceSafe events (BeforeCheckin, AfterCheckin etc.) through c# and interop. I've used tlbimp on SSAPI.dll to get access through c#.
In the Init() function I subscribe to events (BeginCommand += new ....) and the rest.
I change by ssaddin.ini file appropriately. When I open SourceSafe, my Init function gets called the way it should.
The only event handler that gets invoked consistently is the EndCommand handler. Depending on the order in which I subscribe to the events (+=), I can get different event handlers to be invoked but I can never get all of them invoked. (unexpected)
Looking at what tlbimp generates as a signature for the event handlers I came accross something strange. The BeforeAdd method (for example) expects as a first parameter a VSSItem, but if I implement the interface in Visual Basic 6, the signature for the same method expectes a IVSSItem.
Can anyone point me in the right directed to how I can get this working. I'm all out of ideas.
Thanks in advance.
|
|
|
|