|
I want to create a method that checks to see if a row or a table is currently locked in SQL Server ..
I want the method to accept a table name and key and then return true or false.
The only thing I can't seem to understand is what code do I write or how do you check to see if a table or row is locked in SQL Server ????
Thanks in advance ..
GBX ..
|
|
|
|
|
The first question is WHY?
The record state can change between the time you look at its state and the time the state is returned back to the client. Every time you look at the record state, the information is already out of date.
|
|
|
|
|
yeah good point .. thanks ..
jon
|
|
|
|
|
It's just not worth the effort.
Simply handle Exceptions when they happen.
|
|
|
|
|
I have an interesting requirement and was wondering if anyone might be able to point me in a direction that could get me started.
I've developed an application that is used on many workstations in the company and all access the same database. From time to time I see little issues in the DB that I can't figure out how a user might have managed to make the particular change. It might be a bug in my code but it's such a difficult issue to debug as I usually can't even replicate the problem.
So I was wondering if it would be possible to write some or other function that is called every time the user clicks on any control on the form. This procedure then stores the name of the control, the date and time and perhaps even the coordinates of the click (or something like that) to a List which can then either be written to a local log file or to some table in the DB. This way I'd be able to see exactly the sequence of clicks that preceded a certain change in the DB.
The problem is, the application is huge and I don't want to go add a line of code that calls this function at the start of every OnClick() event handler. Is there a way I could have my function called for every click that happens on any control in any form in the application before the relevant OnClick() event handler is called?
Any ideas on alternative approaches that might help me track the users' mouse clicks would also be very welcome.
|
|
|
|
|
Dewald wrote: Any ideas on alternative approaches that might help me track the users' mouse clicks would also be very welcome.
To start off; not every user uses the mouse. I'm using a keyboard simply because it's faster to hit a shortcut then it is to find the cursor, point to mouse to a specific region and click twice. And again, because the first mouse-click wasn't registered.
What you'd like to trace, are the methods that are being executed. It sounds like PostSharp[^] could be helpful here.
A lightweight solution would be to iterate through all the components of a form, and register an extra handler for the most interesting events, and log those.
Bastard Programmer from Hell
|
|
|
|
|
OK, that sounds like a good approach. Thanks. I'll investigate that.
|
|
|
|
|
You're welcome
|
|
|
|
|
To start off; not every user uses the mouse.
This is true but buttons and menu items still fire 'click' events even if you select them with the keyboard (and, personally, I'd recommend you do this with any custom controls you write that have an action on click, too).
|
|
|
|
|
BobJanova wrote:
This is true but buttons and menu items still fire 'click' events even if you select them with the keyboard (and, personally, I'd recommend you do this with any custom controls you write that have an action on click, too).
Yup - but I still see a lot of buttons that only react on their Control.MouseClick event - just wanted to touch the subject to ensure that it's not overlooked
Bastard Programmer from Hell
|
|
|
|
|
hi...i am using rdlc report in c#.net 3.5 and vs2008.
i want to enter a page break after a group...plz help me i use page break at end property but its not working fine.report generates blank pages in between.
|
|
|
|
|
hi every one,
I want to get current application windows title and then show it?
through my search,I find out that I should use getforegroundWindow(),but I don't get it how to do that ?
I'd appreciate any help.
|
|
|
|
|
To use C++ functions you need to do some research into P/Invoke.
Here's how to declare the functions you need in C#:
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplicationTest
{
internal static class NativeMethods
{
[DllImport("User32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("User32.dll")]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
}
}
Usage example:
using System;
using System.Text;
namespace ConsoleApplicationTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press any key to get text");
Console.ReadKey();
IntPtr handle = NativeMethods.GetForegroundWindow();
if (handle != IntPtr.Zero)
{
StringBuilder builder = new StringBuilder(255);
NativeMethods.GetWindowText(handle, builder, builder.Capacity);
Console.WriteLine(builder.ToString());
}
Console.ReadKey();
}
}
}
I have used a hardcoded max length of 255. You can use GetWindowText[^] to get the length of the text before getting the text so you won;t be wasting memory with your string builder or risk truncating if it's longer than you expect.
I'll leave implementing that (which is simple) as an exercise for you.
modified 18-Jun-12 17:55pm.
|
|
|
|
|
1. I have a binary c++ exe. (Proj1)
2. This exe launches another exe (a c# one).(proj2)
3.I have the source code for proj2.
4. When Proj1 calls Proj2 (click of a button), I want to step into the c# code of proj2.
5. I added a Debugger.Break() as the first line in proj2 c# code.
5. I started proj1 running.
6. FRom Proj2 Debug menu, i tried "Attach to Process" the running process proj1.exe.
It attached.
7. I tried to put a breakpoint on Debugger.Break() line. VS 2008 said breakpoint will not be hit , no executable code is associated with this line.
8. I clicked the button in proj1.exe which launches the c# project (proj2).
9. The gui of proj2 came up but did not step into the source code at all.
Evidently I'm doing something wrong.
My goal is to step into the C# source code of proj2 when the binary exe proj1, launches proj2.
thanks,
sb
|
|
|
|
|
Make sure you're building proj2 in Debug, not Release (because I'm pretty sure debugger stuff is stripped out in Release builds).
|
|
|
|
|
Thanks!
It's definitely built in debug mode.
sb
|
|
|
|
|
bonosa wrote: 6. FRom Proj2 Debug menu, i tried "Attach to Process" the running process proj1.exe
That's the reason: you have to attach to proj2.exe.
|
|
|
|
|
From proj2 source code in VS 2008 attach to proj2.exe after starting proj2.exe from proj1.exe? I did that and it did not step into the code. In order to attach proj2 src code from VS2008, proj2.exe has to already be running. It seems circular?
thanks,
sb
|
|
|
|
|
It's not circular. If you want to debug proj2.exe you have to attach the debugger to it. It'll step into the code, but proj2 might be at an idle state when you attach the debugger, so you may have to pause the execution after the debugger attaches. At that point, execution may, or may NOT, be inside your code but inside system code.
If you set a breakpoint in the proj2.exe code and the execution has already gone past, the code won't stop until the breakpoint is hit again or execution ends.
|
|
|
|
|
I am using the following:
Mycontrol.DisplayFormat = "Total: {0}";
It displays the number as it so if it is 1.250 it will show 1.25
How can i force format to 3 decimal points?
|
|
|
|
|
Try:
Mycontrol.DisplayFormat = "Total: {0:F3}";
should give you data till 3 places.
C: Displays numeric values in currency format.
D: Displays numeric values in decimal format.
E: Displays numeric values in scientific (exponential) format.
F: Displays numeric values in fixed format.
G: Displays numeric values in general format.
N: Displays numeric values in number format.
X: Displays numeric values in hexadecimal format.
|
|
|
|
|
Thanks alot
|
|
|
|
|
I use Sql Reporting Services to create the report for an application.The reports are loaded in a web page using the ReportViewer.
My need is to be able to set in advance the Number of copies for a specific report.
I dont want to rely on the user to change the number of copies every time the report is produced, so i want the print dialog box of the Report Viewer ActiveX control to display Number of Copies = 4
|
|
|
|
|
Ok here is the whole code and the problem is right down the bottom with the myDice which I have underlined. Ok I deleted most of the code apart from where the error is
Error.... The name 'myDice' does not exist in the current context
Everything else works fine just not this part!
public int AddUpDice(int DieNumber, int[] Dice)
{
int Sum = 0;
for (int i = 0; i < 5; i++)
{
if (myDice[i].RollNumber == DieNumber)
{
Sum += DieNumber;
}
}
return Sum;
}
}
}
|
|
|
|
|
Rather than dumping the entire code you need to provide the exact error messages produced by the compiler.
[edit]
A quick run of the IDE shows that myDice is declared in the Form1 class and you are trying to access it from the CalculateScore class. However this is not possible without qualifying the name. As I said in answer to a number of your other messages, you should spend some time studying the basics of C#.
[/edit]
|
|
|
|