|
hi there...
This is regarding reading events from event log viewer of windows.
I am working on an application which prints the event log entries on the console.
Basically I am NOT directly connecting to event-viewer. Rather I am provided with a dll, which is reading events from eventviewer and sending the instance id to my application.
I could manage to get the event-id from instance id.(with the help of hexadecimal code 3FFFFFFF)
But the problem is that
I need to get the instance id from event id...
We know that instance id is combination of eventid and some 16 bits(with 2 bits on) before it.
But if somebody can tell me on what basis the value of first two bits is set, we can find the instance id from event id - I hope
As far as, I realised is that... if the event is information we get the bits 01.
but the values keep on varying when it comes with warning or error.
(can someone help me out, to find the Instanceid from event id...)
Thanks
Rahul
|
|
|
|
|
Hi... Sorry for my english...
I have this code...
<br />
<br />
public void Connect()<br />
{<br />
NpgsqlConnection cnxPg = new NpgsqlConnection("Connection string...");<br />
cnxPg.Open();<br />
}<br />
<br />
public void pgSelect(string strQry)<br />
{<br />
if(cnxPg.State.ToString() == "Open")
{<br />
NpgsqlCommand npgComm = new NpgsCommand(strQry);<br />
}<br />
}<br />
Ok... firs that all... that doesn't works
Then i want to do something like this...
<br />
public void pgRow()<br />
{<br />
}<br />
How can i return the connection to use it in other functions? How can i return the query results to uset it in other functions too?...
Did you understand me?... my english it's not so good, so i did my best...
Please help me
Thank you all
|
|
|
|
|
Spiderk wrote: NpgsqlConnection cnxPg
This is a local variable, it needs to be a member variable.
Spiderk wrote: that doesn't works
Your error is obvious enough that I worked it out, but in future, posting your error message is a lot more helpful than 'that doesn't works'
Spiderk wrote: How can i return the connection to use it in other functions?
Make it a member, or make it a lazy initialised property, so the property recognises if the connection is null, and creates it, then returns it.
Spiderk wrote: How can i return the query results to uset it in other functions too?...
By setting a return type other than void. For example, an array of entity objects, or a DataSet or DataTable.
It seems to me that you're stumbling on some entry level stuff, have you been using C# for long ? It looks to me like you need to work through some basics before you worry about databases or forms.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: Spiderk wrote:
that doesn't works
Your error is obvious enough that I worked it out, but in future, posting your error message is a lot more helpful than 'that doesn't works'
Ok ok... don't be mad XD...
Christian Graus wrote: Spiderk wrote:
How can i return the connection to use it in other functions?
Make it a member, or make it a lazy initialised property, so the property recognises if the connection is null, and creates it, then returns it.
How can i do that??...
Christian Graus wrote: By setting a return type other than void. For example, an array of entity objects, or a DataSet or DataTable.
Ok... thanks... i will investigate it that later...
Christian Graus wrote: It seems to me that you're stumbling on some entry level stuff, have you been using C# for long ? It looks to me like you need to work through some basics before you worry about databases or forms.
Actually, i don't have too much time with c#... but i want to learn about connecting this...
Be more patient man... i'm not perfect ...
Thanks anyway for your answer and for waste your time in my question
See ya...
|
|
|
|
|
Spiderk wrote: Ok ok... don't be mad XD...
I'm not mad, I'm just trying to point out how your comments don't actually provide all the info you could give to help us help you.
Spiderk wrote: How can i do that??...
private string _s = null;
public string S
{
get
{
if ( s == null)
{
_s = "This string is lazy initialised";
}
return _s;
}
}
That's a lazy initialised property.
Spiderk wrote: Be more patient man... i'm not perfect
I'm just trying to help, but it seems to me that you're a little out of your depth, hence my advice.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello, today I needed to rename a folder and it would not let me do it. The error message said that file may be locked by a process. So I rebooted,thinking it would kill the process, and then tried to rename the folder and it still failed . So then I went to ProcessExplorer and search the output from 100 of the running processes that had the keyword Java in it.
This was very time consuming . I want to write a utility that would search through process tables and look for the process that has a lock on the specified file or folder.
Problem is that I have no idea where to start. I don't know how to read all of the process tables. I don't know what to check in the process table to determine what it has locked and how to kill the lock, if I wanted to. What is the structure of the process table? Do I need special permissions to access it?
I would be very appreciative if someone could help me!
|
|
|
|
|
|
if i have a multi-threaded client server(lets consider 1 server and many clients).and i have to run a .exe file on my server. and i want each of the user threads which contains data to go to the .exe file which will run with these inputs and then reply the output back to the client through the server.
Is this possible??
I really Appreciate ur help
|
|
|
|
|
Sounds like you want a web service on the server, perhaps ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
As Christian said possibly a web service, or .NET Remoting if the clients are all on the same network. Another form would be a Windows Communication Foundation if your up to it.
only two letters away from being an asset
|
|
|
|
|
While playing around with a Black Jack program, I got wondering about the best way to do a decision matrix in C#.
What I am thinking of is basically a 2 dimensional matrix with each row/col combination containing a value representing 1 of a number of different options (e.g. Hit, Stand, Double, Split, etc).
Is a 2 dimensional array the best way to implement it, or is there a better method?
Any opinions?
David Wilkes
|
|
|
|
|
amatbrewer wrote: While playing around with a Black Jack program, I got wondering about the best way to do a decision matrix in C#.
What I am thinking of is basically a 2 dimensional matrix with each row/col combination containing a value representing 1 of a number of different options (e.g. Hit, Stand, Double, Split, etc).
Is a 2 dimensional array the best way to implement it, or is there a better method?
That seems pretty elegant to me, but what you're proposing is only good for evaluating the 1st move of the hand. If one axis represents what the dealer is showing, and the other axis represents what you have showing, it's a very fast lookup of what to do.
After the first move, you either need to code a more traditional if {} else {} type code construct, or have another decision matrix, since you don't have options like splitting and doubling-down available to you after the first decision...
The pure decision matrix approach scores higher for me than the if {} else {} construct for your purpose because:
1) Once the array is initialized, evaluating decisions is very, very fast
2) If you structure your code properly, your intentions are perfectly clear. You cannot mess up the logic.
Pseudo-code:
enum Action {
Hit = 0,
Stand = 1,
DD = 2,
Split = 3
}
private static Action[][] _decision = new Action[][]
{ new Action[] */ 2 */ { Hit, Hit, Stand, DD, Hit, ... },
new Action[] { Hit, Hit, Stand, Hit, DD, ... },
.
.
.
new Action[] { Stand, Stand, Stand, Stand, ...}
}
private static Action Decision(Int32 dealerShow, Int32 meShow) {
return _decision[meShow - 2][dealerShow - 2];
}
Share and enjoy.
Sean
|
|
|
|
|
Thanks for the reply!
Blackjack got me thinking about it, but I can think of a number of projects (current and proposed) that this could be useful for.
I appreciate your example; it is much more elegant then what I was originally thinking of. Not sure I understand the syntax of “Action[][] _decision” and “private static Action Decision(Int32 dealerShow, Int32 meShow)” but it gives me something to research.
Thanks again!
David Wilkes
|
|
|
|
|
|
I have an application that creates Word documents. I can create and close any number of documents while in the application. But when a document is created in my application and another is created outside of the application, exiting both leave the instance of Word running the task manager.
After some investigation, I noticed that launching Word creates a new instance and obviously an associated PID value shows up in the Task Manager. Launching Word again just adds another handle to the initial Word process, not another instance to the Task Manager; thus the PID has two handles to Word documents.
When you exit one of Word documents, the handle remains (OpusApp?) and is enabled but not visible. Still two handles, but one is visible and the other is not. When the last Word instance is exited, everything is cleaned up, all handles of Word are release, and the process is removed from the process manager.
My problem is this:
I create a word document in my application (new PID)
I go outside the my application and launch Word (i.e. Start Menus->Word)
I now have one entry in the Task Manager (from my application) and the second Word document is attached to it with a new handle.
I close the second Word document, the document closes, but the handle remains enabled, but not visible.
When I close the document I created, Word remains in the Task Manager because I’m checking (application.documents.count) to see if there are anymore instances of word documents out there and there is because this handle is still hanging around in the instance I create even though its not active.
Is there a better way of doing this? Or checking that documents are visible?
Am I just way off base?
Thanks,
Eric
|
|
|
|
|
I had same problem before.
This is what I have to do to close the document and application so the instance won't be in task manager. I am not so sure how you are closing your document.
I close word document programmatically thought.
public void CloseMSWord()
{
msWord.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
msDoc.Saved = true;
msDoc.Close(ref msfalse, ref optional, ref optional);
msWord.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
msWord.Quit(ref optional,ref optional,ref optional);
msWord = null;
}
Sinc I'm only using word applicatino one at a time, I make sure the Word process is not running in task manager by using following code.
public void KillProcessByName(string processorName)
{
try
{
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName(processorName);
for(int i=0 ;i
|
|
|
|
|
pnpfriend,
Thanks for the reply. I'll give it a try.
Regards,
Eric
|
|
|
|
|
Your image is a bit small, can't tell waht you are pointing out or what you mean.
only two letters away from being an asset
|
|
|
|
|
sorry:
http://img105.imageshack.us/my.php?image=pointerua1.jpg
|
|
|
|
|
Hi
I am trying to get the list of cells that contain Today(), curretPath, filename function.
Following is my code to get the list of all the formulars on the sheet.
formularRange = excelSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeFormulas,Excel.XlSpecialCellsValue.xlNumbers);
if((bool)formularRange.Cells.HasFormula)
{
System.Array formulars;
if((bool)formularRange.Cells.HasArray)
formulars = (System.Array)formularRange.FormulaArray;
string colname = formularRange.Cells.Name.ToString();
}
Hope this help.
thanks
-- modified at 17:52 Wednesday 30th May, 2007
|
|
|
|
|
Error
------------
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
-------------
i try to use this code
but i have error
***************
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main()
{
// Create a request for the URL.
WebRequest request = WebRequest.Create("https://isp.paltel.net/login.cfm");
// If required by the server, set the credentials.
request.PreAuthenticate = true;
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Display the status.
Console.WriteLine(response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();
Console.Read();
}
}
}
***************
Palestine
|
|
|
|
|
Please don't re-post your question. Did you check out the
HttpWebRequest.ClientCertificates ?
Thanks,
Ben
|
|
|
|
|
Well i want to run a report for a specific record for which i have gotton help from code project but some part the that code gives Error.I am using Visualstudion.Net 2003 C#. the code is
//Instantiate variables
ReportDocument reportDocument = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
//Set instances for input parameter 1 - @vDepartment
paramField.Name = "@vDepartment";
//Below variable can be set to any data present in SalseData table, Department column
paramDiscreteValue.Value = "South";
paramField.CurrentValues.Add(paramDiscreteValue);
//Add the paramField to paramFields
paramFields.Add(paramField);
crystalReportViewer1.ParameterFieldInfo = paramFields;
reportDocument.Load(@"..\..\..\Reports\SalseReport.rpt");
//Load the report by setting the report source
crystalReportViewer1.ReportSource = reportDocument;
the bold instructions are the errors .Actually in VS2003 we don't have obj.Name() and obj.CurrentValues.Add() functions but obj.Set_ParameterName() and Set_ParameterCurrentValues() function. when i used these instead of these,it gave me error saying that function can not be called explicitly or invalid call access operator.
waiting for everyone's solution. thank you
-- modified at 12:46 Saturday 2nd June, 2007
By Lucky Hamad
|
|
|
|
|
Hi!
i want to sort an array containing DateTime of this format: 4/5/2007 8:43:34 PM, in ascending order, i.e. latest date/time on top...
Please give any ideas about this issue...
Thanks in advance...
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
Probably a better method exists, you can anyhow try this.
Store the dates in binary format in an ArrayList. Do an ArrayList.Sort() and Arraylist.Reverse(); .
You can store date in binary using .ToBinary(); method and retrieve using DateTime.FromBinary(longDate) method.
|
|
|
|
|