|
Nope, still getting the same exception.
Jeff
|
|
|
|
|
In the app I'm writing I would like to be able to check if any concurrency violations have occurred on the database it's monitoring in the recent past.
In SQL Server Management studio I can run the command
DBCC CONCURRENCYVIOLATION
which gives me the message back (where I forced concurrency violations):
Concurrency violations since 2007-10-10 10:47:47.383<br />
1 2 3 4 5 6 7 8 9 10-100 >100<br />
4727 2800 1118 0 0 0 0 0 0 0 0<br />
Concurrency violations will be written to the SQL Server error log.<br />
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
So this is the info I need, the way that I'm trying to get it into my program is:
conn.Open();<br />
<br />
conn.InfoMessage += new SqlInfoMessageEventHandler(SqlMessageEventHandler);<br />
<br />
SqlCommand c = new SqlCommand("DBCC CONCURRENCYVIOLATION", conn);<br />
c.ExecuteNonQuery();
where conn is my SQL connection and SqlMessageEventHandler grabs the error message:
public void SqlMessageEventHandler(object sender, SqlInfoMessageEventArgs e)<br />
{<br />
string CVTest = "";<br />
foreach (SqlError err in e.Errors)<br />
{<br />
CVTest += err.Message;<br />
} <br />
<br />
}
The problem is that the "CVTest" sting I'm using to monitor the message only gives me back
DBCC execution completed. If DBCC printed error messages, contact your system administrator. rather than the whole message as in Server Management Studio. This occurs whether the DB I'm checking has violations logged or not.
Does anyone know how I can get all the information that DBCC CONCURRENCYVIOLATION should return?
Alternatively, if anyone knows a better way to programatically check for concurrency violations that have occurred on the database that would be great, since parsing that message to determine can't be the most efficient way.
Thank you.
|
|
|
|
|
I might be wrong but have you looked at what is inside the Message property of the SqlInfoMessageEventArgs in your case:
public void SqlMessageEventHandler(object sender, SqlInfoMessageEventArgs e)
{
string CVTest = e.Message;
foreach (SqlError err in e.Errors)
CVTest += Environment.NewLine + err.Message;
}
Robert
|
|
|
|
|
Hey, thanks for the reply. Yeah, the Message property only contains that one line response as well instead of the whole message.
Anyone have any other ideas on how to check for concurrency violations?
Thanks
|
|
|
|
|
Hi all,
I'm having some trouble getting with this:
char temp = System.Console.ReadKey();
//Throws an exception
So I tried System.Console.ReadKey().KeyChar which returns the ascii value of the key I entered...
Basically I need to get a key that falls in the range of 0-10
There's a validation line that handles if temp > 0 || temp < 10... but I can't get the character to convert into an int properly.
Thanks
Humble
|
|
|
|
|
if (Char.IsNumeric(Readkey().KeyChar)) should tell you if it's a number of not.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yeah, I've got the validation portion down...
I need to get the character, which if entered proprly is an integer number, and convert it into an integer for processing.
|
|
|
|
|
Probably an easier way but this seems to work:
int val = Convert.ToInt32(e.KeyChar.ToString());
Good Luck!
“You can't teach people to be lazy - either they have it, or they don't.”
-Dagwood Bumbstead
|
|
|
|
|
Hi all!
I must set a psw to a directory, any ideas??
thanks
Bye
|
|
|
|
|
What is a "psw"?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
TJoe wrote: What is a "psw"?
I guess he means password
|
|
|
|
|
|
The short answer is that you cannot set a password on a folder.
The long answer is that it can be done, but is a total waste of time considering all the work you're going to have to do in C++ to pull it off writing NTFS file system extensions, a management tool to reset passwords, a database manager to maintain the password database, ...
Some of this stuff could be written in C#, but no the extensions to NTFS.
It's a complete waste of time betwen NTFS Security handles all of this and the users doesn't need to remember yet another password on top of the 5, 10, 15, 20+ passwords they already have to remember.
|
|
|
|
|
It's not really something you would do from C#, but I'm sure it's possible. Here is how to do it using Windows[^].
What exactly are you trying to accomplish? Are you trying to secure some files for your users, hide files from them, etc?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi, i must set a password to a directory beacause i'm try to secure some of my files...
Bye
|
|
|
|
|
How can I get the current open file of WORD, POWERPOINT and OUTLOOK.
say that im gonna print them or convert them from to tiff.
Using .NET and c#
it should be getcurrentfile(); or smthn any help?
thnx
|
|
|
|
|
I have combed the net for an answer to this and I can't seem to find one; am I missing something?!?
I currently have an application (C# Windows Form) that launches a C++ command-line tool with an myriad of command arguments. The C# application asynchronously captures the output and redirects it to a RichEditBox. I would like to restructure the tool and recompile it as a DLL but the code is riddled with printf statements. I've done small test cases with a simple printf inside of an otherwise empty function (in the DLL) but nothing shows up and I am unable to redirect it's output.
Has anyone solved this problem?
|
|
|
|
|
You can't redirect the printf output. It's going to go to the StandardOutput stream no matter what. You CAN redirect the StandardOoutput stream, but I believe that requires a console window to do. In other words, I don't believe you can't redirect it from a DLL since there is no StandardOutput stream without the console.
|
|
|
|
|
Hello all,
Odd title, not an easy one to summarise. Basically I am trying to find a way of access an object value from a string that contains that objects name.
So, lets assume I have the following basic class
class NoddyClass
{
public string foo;
public string bar;
}
Which is used by the following
class NoddyProcess
{
private NoddyClass nc;
public NoddyProcess()
{
this.nc = new NoddyClass()
this.nc.foo = "thingys";
this.nc.bar = "doodars";
}
public void GetValueFromString(string value)
{
}
}
class AnotherNoddyProcess
{
private void DoSomething()
{
NoddyProcess np = new NoddyProcess();
np.GetValueFromString("foo");
}
}
So putting all this together in the GetValueFromString method I need to access this.nc and using the passed string retrieve the value of this.nc.foo and return it to the caller.
I am assuming that this can be done with reflection, however I seem to have hit a wall on this and could do with a prod in the right direction.
P.S. I realise that in the examples given above none of this is actually necessary, however these are extemely simplfied versions of a much more complex framework.
|
|
|
|
|
Since you are accessing fields, check out this[^]. It has an example that should get you started.
For properties, check out this[^].
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
MrEyes wrote: however these are extemely simplfied versions of a much more complex framework.
This "much more complex framework" is what? Or is it what you are developing?
|
|
|
|
|
Basically I have a library that has an encrypted XML file sat underneath it, when the library object is created it reads in, decrypts and deserialises the XML to an class level object. This object is then used within the library to drive various things.
This library exposes a COM interface to allow none .NET applications to interact with it, and until today these external applications did not require the ability to directly extract data from the XML file.
Today however, this functionality is now a requirement.
The XML itself while structurally simple, contains alot of elements. In fact it looks something like this:
<Data>
<Element1></Element1>
<Element2></Element2>
....
....
<Element1000></Element1000>
</Data>
Due to the volume of elements it isnt really feasible to create an externally accessible property for every single one, i.e:
public string GetElement1Value
{
return this.myXmlObject.Element1
}
There was also the option of not using the current XML object in memory, re-reading, re-decrypting it, and then using XmlDocument and Xpath to get the value, however I belive the overhead here would be greater than using reflection.
So this is where the idea of using reflection comes in. In fact since posting I have found a solution, so this is what I am currently trying out:
public string GetConfigurationValue(string key)
{
Type itemType = typeof(MyXmlObject);
PropertyInfo property = itemType.GetProperty(key);
if (property == null)
{
throw new ArgumentException("Invalid XML element key", key);
}
return property.GetValue(this.myXmlObject, null).ToString();
}
Which as you can see is alot shorter than using 1000+ property accessor/methods.
Maybe I am barking up the wrong tree here, so feel free to point out something that I have considered as I have to admit using reflection doesnt sit very well with me.
|
|
|
|
|
MrEyes wrote: In fact it looks something like this:
WOW... I am sorry but using XML in that way crosses my threshold of acceptability. I am afraid I cannot assist you any further.
|
|
|
|
|
Ack.. you may want to reconsider this approach. Did you know that you can use XPath queries in XML documents using the XmlDocument class in .NET? This might serve your purpose alot better than attempting to manually extract fields in this manner.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
This appeared to work for me, and I think it's what you want, using reflection. Note the Main method and GetValueFromString method. (Sorry for the formatting)
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace ConsoleApplication1
{
class Program
{
static void Main(string [] args)
{
NoddyProcess p = new NoddyProcess();
object o = p.GetValueFromString("foo");
Console.WriteLine(o.ToString());
o = p.GetValueFromString("bar");
Console.WriteLine(o.ToString());
Console.Read();
}
}
class NoddyClass
{
public string foo;
public string bar;
}
class NoddyProcess
{
private NoddyClass nc;
public NoddyProcess()
{
this.nc = new NoddyClass();
this.nc.foo = "thingys";
this.nc.bar = "doodars";
}
public object GetValueFromString(string value)
{
FieldInfo info = nc.GetType().GetField(value,BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public );
return info.GetValue(nc);
}
}
class AnotherNoddyProcess
{
private void DoSomething()
{
NoddyProcess np = new NoddyProcess();
np.GetValueFromString("foo");
}
}
}
|
|
|
|