|
That depends on what you're using. If you're .Net 2.0 and all on the same machine, just use the System.Transactions namespace. Open up a TransactionScope and every call that gets made within that will subscribe to that transaction automatically. If you're in .Net 1.1, you could use COM+ (System.EnterpriseServices) and carry the transaction that way. If you're on different machines separated by web services or remoting, it gets a little more complex. In .Net 1.1 and 2.0 you can use TIP (Transaction Internet Protocol), which is a part of COM+ to handle transactions across machines. But an even better solution comes with .Net 3.0 where WCF gives you the ability to carry transactions across services very easily.
I have an article on TIP[^] and an article on WCF[^] that explains how to spread those transactions across machines. Essentially you can start a transaction in the presentation layer and even if the DAL is on another machine, it can subscribe to it.
|
|
|
|
|
ok. Everything is on one machine... i'm going to try with TransactionScope then, and look for some article. Thanks for answer this Dustin, i needed the advice because i'm just starting using layers.
Never argue with an idiot. They drag you down to their level, then beat you with experience. - Dilbert
|
|
|
|
|
Hello,
I have a .MHT file with my C# application, I use WebBrowser control to navigate to it at runtime. Is it true that the user should have outlook installed in order to display the mht file correctly as it's stated on MS site:
NOTE: "Web archive" is available only if Outlook Express is installed. The ability to save a Web page as a Web archive file is provided by the Inetcomm.dll file (the Microsoft Internet Messaging API file), which is installed by Microsoft Outlook Express 5.
http://support.microsoft.com/kb/221787
Please advice. Thanks.
|
|
|
|
|
I take it as gospel, after I tried it without Outlook Express installed. BTW, I think OE is installed by default in every Windows installation since Windows 98. You'd probably have to build a machine from scratch to test this. A Virtual Machine, like VMWare or Microsoft's Virtual PC, is great for stuff like this.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You might check for the existence of the file Inetcomm.dll
I found mine in C:\WINDOWS\system32\
string path = "%SystemRoot%\system32\Intercomm.dll";
path = System.Environment.ExpandEnvironmentVariables(path);
bool isExist = System.IO.File.Exist(path);
A better way might be to try to load the outlook object as a com object though. Then, if someone decides that library should get merged into another library, or decides to change the filename, or decides that dolphins should rule the earth, then you will still be golden if someone was smart enough to leave the functionality somewhere that the com object can get to it.
|
|
|
|
|
I have a custom control that I has embedded controls.
When I show a messagebox, the messagebox shows up behind the form.
Topmost on the form is set to false.
OpenFileDialog works as it is supposed to, why not messagebox?
Any ideas?
private void button13_Click_1(object sender, EventArgs e)
{
item i = new item();
Button b = new Button();
b.Text = "hello";
b.Click += new EventHandler(b_Click);
subItem s = new subItem("hello");
s.EmbeddedControl = b;
i.SubItems.Add(s);
this.myListView1.Items.Add(i);
}
void b_Click(object sender, EventArgs e)
{
//using (OpenFileDialog dlg = new OpenFileDialog())
//{
// dlg.ShowDialog(this);
//}
MessageBox.Show(this, "hello");
}
|
|
|
|
|
Instead Use MessageBox.ShowDialog(),
if u deliberately want to use MessageBox.Show mean pass the mainform's handle as the first parameter(owner) of Messagebox.Show
|
|
|
|
|
Hey all,
I'm encapsulating the SetWindowsHookEx() function in order to capture all keyboard messages.
I'm raising KeyEventHandler events from my class, so I'm planning to use the KeyEventArgs object, of course.
When capturing keyboard messages I get the key-code for the pressed key.
To instantiate a KeyEventArgs object, I need a System.Windows.Forms.Keys value.
Anybody got an idea as for how to get the appropriate Keys value
without using a large switch statement involving a case for every key on the keyboard??
Thanks in advance,
Shy.
|
|
|
|
|
I think you can just cast them, the Keys enumeration has the appropriate values defined for each character code.
Sig cops got me...
|
|
|
|
|
What about the numpad keys, space bar, etc...?
BTW... Is there any way to print the value of an enum?
Something like:
Keys k;
k = Keys.A;
Console.WriteLine(k.ToString()); The above code prints "A" BTW...
|
|
|
|
|
You could do:
Console.WriteLine("{0}.{1}", k.GetType().Name, k.ToString()); That's the simplest way I think.
Sig cops got me...
|
|
|
|
|
You could do:
Console.WriteLine("{0}.{1}", k.GetType().Name, k.ToString()); That's the simplest way I think.
Sorry forgot to answer your first question. The NumPad keys etc are still characters, just assigned a value outside the normal "visible" range. E.g. Esc is char(13) I think.
Sig cops got me...
|
|
|
|
|
Thanks, but that's not what I was looking for...
I want to be able to print the key code...
k.ToString() returns the name of the key...
|
|
|
|
|
Ah, I see what you want, cast it to an int then and you get the value
Console.WriteLine((int)k);
Sig cops got me...
|
|
|
|
|
Thanks a bunch!
|
|
|
|
|
I have a problem when trying to close a connection or the odbcdatareader if I stop it from doing Read() before it would normally be done it hangs. I saw something similar when I Googled this a while ago, but can't find it now. Apparently, the while(dr.Read()) doesn't actually stop even though I used a break; to get out of the while() loop. Anybody run into this before?
|
|
|
|
|
show is a small code snippet of the loop. I have a feeling you're missing something that is causing the loop to continue, and not actually hitting the line to break out of the loop.
|
|
|
|
|
No, I don't think that's it because it breaks from the loop with no problem. I put a breakpoint on the line immediately following the loop and it goes directly there with no problem. This function is being done in a thread of its own so that the user can press 'Cancel' and also updates the UI correctly.
Here's a snippet of what I'm doing:
while (statreader.Read() && !m_bCancel)
{
stemp = statreader["aj_vchar"].ToString();
this.progressBar1.Increment(1);
}
this.progressBar1.Value = 0;
statreader.Close();
I've tried calling Close() on the connection first. I've tried calling Dispose() instead, and I've tried not closing it at all to see what happens when it goes out of scope (statreader). No matter what, this reader hangs on close depening on how many records are in the reader.
When I try it on a test database that returns only a few thousand records, Close() only takes a few seconds. When I try it on a database with about 400,000 records being returned, it takes about 10 minutes for Close() to finish executing.
|
|
|
|
|
Can you show me where you're opening the connection? I'm guessing this would shed more light. Are you creating the DataReader object with the option "commandbehavior.closeconnection"?
|
|
|
|
|
The following comes directly before what I posted earlier:
using (OdbcConnection conn = new OdbcConnection(source))
{
conn.Open();
statcmd = new OdbcCommand("select * from tblPeople", conn);
statcmd = new OdbcCommand(sql, conn);
OdbcDataReader statreader = statcmd.ExecuteReader();
No, I'm not using "commandbehavior.closeconnection" option. Never knew it existed.
|
|
|
|
|
Just a shot in the dark, can you use a OleDb instead of ODBC and see if the problem persists?
|
|
|
|
|
I can try that, but I just never thought to since I'm using an ODBC connection (DSN). I'll let you know if there's any change.
|
|
|
|
|
just tried that; same result, except this time I got some weird error about not being able to switch from COM this-or-that for over 60 seconds.
|
|
|
|
|
I tried the commandbehavior.closeconnection option; didn't make a difference
|
|
|
|
|
MSDN2: DataReader.Close Method [^]
Remarks
You should close data readers when the consumer has completed reading data or no longer wishes to read any more data. Closing the reader ensures that output parameters, if any, are populated.
Depending on the provider implementation, the Close method may wait for the data reader to finish returning all of the specified data before closing. Compare to the Terminate[^] method.
Suggestion:
If you cannot find a provider that supports the Terminate method, you could split your SQL into chunks of 10,000 or so:
select TOP 10000 * from tblPeople where PeopleID > @nLastID order by PeopleID
Looping and creating a new reader each time until you're done, or the user cancels.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|