|
I did actually. Drag a SqlDataAdapter to your form or control and go through the wizard, specifying that new commands should be created instead of using new or existing stored procs. Take a look at what's generated in your source file.
You can also read the SDK documentation for SqlDataAdapter , which does have examples in various class and method documentation.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
If you do have to browse to find the assemblies and all you find are xml files of the managed assemblies then go here for the latest DirectX 9 managed download: http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp[^]
Just follow the instructs and viola you should have the assemblies. You'll know right away if you've got them installed correctly because when you fire up VS.Net you'll see the green directx logo along with your other languages on the splash screen.
Have fun!
Best,
Jerry
The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark Toasty0.com
|
|
|
|
|
Wrong thread
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Oh damn! Sorry!
The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark Toasty0.com
|
|
|
|
|
Hi,
I want to ask a question about how to return messages from a general class.
How should I warn the users.
When something happened that must not be done what the object must do?
The senario is, there are several classes. Each of them has specific functionality.
It seems to me that the best way is defining a class that has properties like MessageID and and the Message. User can compare the MessageID with the const integers on the class to understand what happens and takes action.
Is there a general approach?
Kind Regards
|
|
|
|
|
From what I have seen everybody has a different opinion on this one.
I say clean up and throw a descriptive exception, but there will undoubtedly be many who will say that is a bad idea and recommend output params or returning strings etc.
But my vote is on exceptions
regards,
Paul Watson
Bluegrass
South Africa
Brian Welsch wrote:
"blah blah blah, maybe a potato?" while translating my Afrikaans.
Crikey! ain't life grand?
|
|
|
|
|
Paul Watson wrote:
But my vote is on exceptions
Ditto. Exceptions are the best way to notify the class consumer of an error.
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
I cast my vote for exceptions, too. A callee can pass far more data about any errors that occur to its caller in a polymorphic way that would be difficult - if not stupid - to do with out params.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
FxCop rocks! Did you know it's included in the Longhorn SDK download?
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
As we know, In The Dialog Window of MSN Messenger We Can Change the BackColor.
How can i do this in C#.Thanks a Lot!
|
|
|
|
|
Type "this." and search through the intellisense. You *should* be able to find it.
|
|
|
|
|
Does someone know how to view a System.Windows.Forms.Panel in a fullscreen mode?
Thanks in advance for your help ,
Thomas
|
|
|
|
|
You can't display a Panel without a parent window, but you can display a Form with that Panel in fullscreen mode (it's just how window managers work).
If you want the form maximized, just set its WindowState property to FormWindowState.Maximized . If you want it to be really full-screened (like a game normally would be), it's similar: set FormBorderStyle to FormBorderStyle.None , and then set WindowState to FormWindowState.Maximized . The trick is in what the BorderStyle property does under the cover, since it's really just a wrapper for a dialog in Win32. See the Windows Styles for more information if you're interested.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
I'm creating a windows form that has master-detail data on it.
I've implemented my own classes that take care of the bussiness logic and retreiving/writing data from/to database.
When I change the master record I call a method from the detail class to retrieve all the detail rows from the database and put this into dataset.tabel and then I return the default dataview to the method of the form. Then in the method I change the datasource of the datagird to the new dataview. This is very slow (I have to wait for 1 second for data to come up on the datagrid.
Please help.
<br />
private void FillDetail()<br />
{<br />
dvDetail1=refdata.RetrieveData();<br />
dgRefData.SetDataBinding(dvDetail1, "");
cm_d1 = (CurrencyManager)BindingContext[dvDetail1];<br />
cm_d1.PositionChanged+=g2td1;<br />
Grid2Text_D1(new object(),new System.EventArgs());<br />
}<br />
Dejan Mitev
|
|
|
|
|
First, you should just grab all the data you need into the DataSet , including the master and detail tables. Unless this is an extremely huge DataSet , often-accessed data is better to pull down in one shot.
Then, take a look at a previous thread I posted a solution to in this forum: http://www.codeproject.com/script/comments/forums.asp?msg=665954&forumid=1649&XtraIDs=1649&searchkw=DataGrid&sd=10%2F1%2F2003&ed=11%2F25%2F2003#xx665954xx[^]
Basically, if you bind your master DataGrid.DataSource property to the DataSet and specify the appropriate table in the DataGrid.DataMember property, and then set the detail's DataGrid.DataSource to be the relationship between the two tables (implying that you create a strongly-typed DataSet and form a named relationship between the two DataTable s, which is really easy using the DataSet designer), clicking on a row in the master DataGrid will automatically filter the detail DataGrid with the related child rows. This way, no fetching is required.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you for your quick answer,
I know that the way you are showing in the reply is the preffered way, but I don't trust microsoft in the realisation on the data bindings and I'm just not comfortable with the datagrid control, except for viewing readonly data.
Any way this is a realy huge database (e.g. master table has about 16,000,000 and the detail is about 31 milion record) and I can't put this in a dataset.
So I must stick with this way of retrieving data.
Do you know any particular reason why is setting the datasource of a datagrid so slow. I'm thinking of creating my own control that will display the data (substitute for datagrid).
Dejan Mitev
|
|
|
|
|
The DataGrid does work and we use it a lot in our commercial application. Mostly likely, you're having such problem because the DataGrid loads all records instead of creating a virtual buffer in which to load records as they become visible. You might be better off with a third-part control. There are many out there, just google for them.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
at the moment I'm developing an application, which extensively uses the FileSystemWatcher.
The received events are used by a logic component, which then calls a Third Party API in an appropriate case.
The Third Party is COM based, and is STA Threaded. (I recognized that, after switching on a Stress Test, crashing the whole system...).
For I was a Java Programmer in my former life, I don't have the .Net -KnowHow for to savely implement Mulit-Threading/Synchronisation matters.
(Don't want to crash again)
Important is for this Synch is:
- There mustn't be a timeout. Each Event must be processed!
Are there internal queuing mechanisms (which could overflow?)
What would be the best way?
I saw FileSystemWatcher has a SynchronisationObject Property.
How To handle that?
What delegate to invoke with what args there?
Doesn't that correspond to the FileSystemEventHandler?
I don't understand the Concept behind this Sync...
A Sample would help... thanks in adance!
|
|
|
|
|
Since you're new to .NET, read through all the classes in the System.Threading namespace. You'll find all your answers in there.
The important thing about your solution is that the FileSystemWatcher fires events synchronously. To handle the code in different threads, you have a variety of options. One is to use the ThreadPool , which has a method called QueueUserWorkItem . This creates a worker thread in a thread pool (so that your thread count doesn't skyrocket and monopolize the system resources) and even allows you to pass a state object (which could be a single object, an array, collection, list, etc.) unlike the Thread class (which works better for unit operations in a class that invoked it so it can access - in a synchronized manner if applicable - the class's resources).
The other way is to use delegates with asynchronous invocation (the BeginInvoke that the C# compiler (and some others) automatically generates, which means if you create your own delegate you won't see the BeginInvoke method in your IntelliSense drop-down list, but just type it correctly anyway).
So, to use a ThreadPool (and keep in mind this is very simplistic sample code, so read-up on what I'm talking about before copying and pasting this code), you could so something like the following:
private void myFileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(DoFileDiff), e.FullPath);
}
private void DoFileDiff(object state)
{
string path = state as string;
int changedLines = Diff(path);
lock (this)
WriteToLog(path, "Changed", changedLines);
} Again, keep in mind I'm pulling stuff out of my head as only an example. Pay attention to the lock keyword, though. This resolves to a Monitor , which is in the namespace I mentioned at the beginning. You could also one of the various WaitHandle classes with a little more control over what gets locked and what doesn't, and what thread (in an MTA) has to wait for what other threads (note, too, that Thread.Join is available still with any of these methods I'm mentioning.
Using delegates with asynchronous execution doesn't give you the control you have with the ThreadPool , but if your code is quick it might be worth not using the ThreadPool . You should still reserve using the Thread class for simple cases, since you can't pass state objects to them. The following example will use the same DoFileDiff method as above for brevity:
private void myFileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
{
WaitCallback callback = new WaitCallback(DoFileDiff);
callback.BeginInvoke(e.FullPath, null, null);
} See the Asynchronous Programming Overview[^] topic in the .NET Developer's Guide in the MSDN Library for more information.
Again, any of the WaitHandle classes or the Monitor will work good to synchronize resources. If you do use the Monitor directly instead of the lock keyword, here's what the lock keyword resolves to so you should do something similar:
Monitor.Enter(syncRoot);
try
{
}
finally
{
Monitor.Exit();
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks a lot for your reply... that helps
Imagine the following Testcase:
Goal: The FileEventHandler process EACH event synchronously.
The Test app moves files in and out the watched folder (doforever until I say stop)
Fact is: At the moment, I have a monitor, lock or mutex or whatever for Sync. But if the process needs some time (I simulated this with Thread.Sleep(500) in my code [see below, just using extremes for testing])
the Events get lost, due to timeout(?).
How to handle that issue? The only thing I see is a MessageQueue, which I assume is Thread Safe (am I right?)
Is there a way configuring the FileSysWatcher in a way that these events wont get lost?
private AutoResetEvent ChangedEvent = new AutoResetEvent(true);
Boolean bEventLockAcquired = true;
try
{
Monitor.Enter(ChangedEvent);
bEventLockAcquired = ChangedEvent.WaitOne(0, false);
if (bEventLockAcquired)
{
switch (e.ChangeType)
}
case(WatcherChangeTypes.Created):
Console.WriteLine(e.Name + " " + e.ChangeType +
" Count " + i.ToString());
Thread.Sleep(500);
break;
case(WatcherChangeTypes.Deleted):
Console.WriteLine(e.Name + " " + e.ChangeType);
break;
}
i++;
}
}
catch(Exception ex)
{
log.Error("Error",ex);
}
finally
{
if (bEventLockAcquired)
{
ChangedEvent.Set();
}
Monitor.Exit(ChangedEvent);
}
I would be very greatful for a reply.
Thanks
Wolfram
|
|
|
|
|
You don't need to - and probably shouldn't - use both the Monitor and AutoResetEvent . Use one or the other.
The most likely problem is that you're locking the entire operation - this is virtually equivalent to doing these operations synchronously! Only lock when you need to. For example, unless you're synchronizing the same file between directories at the same time (and be careful, because the Changed event is fired exactly 3 times per changed file, no matter what the size), you can let the file copy operation occur in separate threads at the same time. Just lock when you need to write to the console or a file.
The timeout effect is occuring because the events are piling up and you're locking everything like I said above. You'll need to design your threads (using one of the methods I was talking about) so that the FileSystemWatcher can continue firing events without overloading the event queue so to speak.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello Heath,
I use the msmq Framework now. The Filewatcher sends a message for each event. So, I can Sequentially work through the Messages and call the third-party-API one call after the other without loosing events or get concurrent API calls (with a certain loss of performance I must admit, but conceptual, this API is one big bottleneck... no multithreading, etc. .)
The ReceiveHandler is locked with only a Monitor, as you said.
It works, greetings
Wolfram
|
|
|
|
|
How can i make a control be not confined within the borders of its parent window or parent control? Is that even possible? Example I have a listbox inside a textbox, and is trying to mimic the autocomplete feature. What I want is when the listbox appears it should be completely visible, extending over the borders of the textbox.
|
|
|
|
|
You can actually use the auto-complete services that Windows provides. Take a look at this article: http://www.codeproject.com/csharp/csdoesshell4.asp[^].
And, no, controls can't paint outside their containers. In the case of the auto-complete window, it is an actual popup window so it doesn't have a container to which it's confined. A popup window is positioned and displayed appropriately and communicates with the control with which it's associated. You could also see the Platform SDK documentation for the IAutoComplete interface for more information as well.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|