|
Hi All,
Please tell me how to write XML query in Asp.net.
I hav temple.xml file which contain data of temple.
now i want to apply search on it.
|
|
|
|
|
Load the XML file into XmlDocument instance and write XPath[^] query.
Best wishes,
Navaneeth
|
|
|
|
|
The ASP.NET part is irrelevant. You want to use C#. So, what version of C# do you have ? That will determine if you want to use LINQ or if you need to use the XMLDocument class.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
public class MyClass
{
private string _MyProperty = "the property";
[colName="theColumn"]
public string MyProperty
{
get { return _MyProperty; }
set { _MyProperty = value; }
}
public string GetName()
{
// code to implement
}
}
public class MyClassTest
{
MyClass c=new MyClass();
// I want to get the attribute in the following way:
string colName= c.MyProperty.GetName();
//colName should be theColumn
}
any kind of help would be appriciated.
and it should be in .NET 2.0 framework
|
|
|
|
|
Why do you want to do this ?
The value is going to exist at the class level, you can't change attributes for class instances AFAIK. They are used to specify things for all instances of a class.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I want to do this for the following scenarios:
say I want to Get an object into database.
And I need the column name for WHERE clause
e.g
// Get employees
Get method is like as follows
EmpDA.Get(string filterExpression)
{
//------- the code
}
Employee emp=DAEmp.GetByID(7);
emp.Salary=20000;
EmpDA.Get(string.format("{0}>{1}",emp.Salary.GetFieldName,emp.Salary);
please look at the following factors.
1) I am getting emp list using where clause as "Salary> 20000"
2) But I want to Get the column name "Salary" using emp.Salary.GetFieldName()
thanks for your reply
|
|
|
|
|
As Graus said, i too dont find its a better solution for this problem!
but still, you can get the custom attribute values by the following statement.
colNameAttribute mAttribInstance = (colNameAttribute)c.GetType()
.GetCustomAttributes(typeof(colNameAttribute),false).GetValue(0);
The object mAttribInstance will hold the various properties values within your "colName" attribute class. and you can access them by their respective name..
for e.g if "name" is the string used then,
mAttribInstance.Name will give you the value "theColumn"
Have a Happy Coding.....
|
|
|
|
|
Thanks King Julien for your reply.
I have already used it when interacting with database for insert update fields
but now my problem is to get the column name "theColumn" in the following fashion.
string colName= emp.Salary.GetColName(); //colName should be "theColumn";
look at the GetColName() after the property Salary. emp.Salary.GetColName();
I am using c# 2.0 framework.
|
|
|
|
|
i see...
in that case you may need to create a new class with the function GetColName();
and use it as your return type for property.
example:
Class yourClass
{
public string GetColName()
{
colNameAttribute mAttribInstance = (colNameAttribute)this.GetType().GetCustomAttributes(typeof(colNameAttribute),false).GetValue(0);
return mAttribInstance.Name;
}
}
and u can set the return type of the property salary as yourclass and you will be able to access the GetColName() method!!
Have a Happy Coding.....
|
|
|
|
|
I am looking for an open source component in C# that can be used in a windows application that allows keyboard input (like a DOS command window) and text output on the screen for an embedded command interpreter. I can probably write one myself if need be, but I am working on an open source application and would like to use components like this as much as possible. Does anyone know where I can find such a thing?
Thanks,
Bill
|
|
|
|
|
Um. There is a well hidden part of Visual Studio that might help, but it is not at all obvious how you get to it.
Follow the following instructions exactly:
1) Run VS
2) from the Menu: select File...
3) Select New...
4) Select Project
5) On the dialog, select Console Application
6) Press OK.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thanks, but I'm not looking for a console application, which I am very familiar with. I'm looking for a Form thast can run inside a windows forms application that isn't a text box control but allows both input and out similiar to a command window.
|
|
|
|
|
i get the remote screen picture,but i don't know the cursor position,so that i want to draw a picture to be always follow with the mouse cursor,so i can know where is my cursor in remote computer.
thanks for your help ,i am sorry of my English,wait for you help!
comLee
2009-11-4
|
|
|
|
|
Why can't you see the cursor ? What software are you using ? You can create a program which positions itself over the mouse, just a timer and code to get the cursor position. Sounds ugly tho.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
thanks for you reply,i get the screen by my program
Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics gp = Graphics.FromImage(bmp);
gp.CopyFromScreen(0, 0, 0, 0, new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));
ms = new MemoryStream();
Image im = bmp.GetThumbnailImage(Screen.PrimaryScreen.Bounds.Width / 10, Screen.PrimaryScreen.Bounds.Height / 10, null, IntPtr.Zero);
bmp = new Bitmap(im);
bmp.Save(ms, ImageFormat.Jpeg);
by = ms.GetBuffer();
return by;
i just copy the code from the internet,it can not work for getting cursor of mouse,so i want to draw a picture around the cursor.
i am the first time to ask for help in English,and receive you help so quick ,i am very happy ,thanks a lot!
i just a green hand in programing and English.
Please bear with me
|
|
|
|
|
I'm not sure this does remotely what you want. Yes, the first three lines gets you the screen, and if you used Cursor.Position ( from memory ), you could draw onto that bitmap. But that bitmap is a COPY of the screen, it's not the actual screen.
Why do you need a thumbnail of the screen ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Here I can not access your blog,Do not know how's going on。
|
|
|
|
|
A little background.
I have created a stored procedure in sql server.
That will generate a ##temp table,
then when the stored procedure is complete with generating the table and filling the table with the data for the report,
it will drop the ##temp table.
I want to generate a Crystal Report and or Microsoft Reporting Services Report. The report will need to be generate from scratch in code. Which comes to the part I need help with.
The table will be a minimum of 2 columns to the maximum amount of columns sql server tables will allow. The First 2 Columns are Hard Coded as:
JobNumber int,
[Job Name] [nvarchar](100)
All the other fields are INT. Because the number columns in the report are not static number of columns. I do not know how to generate the report in code.
In the past I would create a xsd and fill the xsd and pre-design the report before with the fields in the xsd. Please I know this is a lot to ask but can someone please give me relevant resources (Websites, Samples, Detailed, Explanation) to research to learn how to accommodate this scenario.
I need to know how to create this report, and In the report I need the column names as well (The column names I think I can handle). I can populate a data grid on the form but I am not sure that that is the right way to do this.
|
|
|
|
|
Hi, we know if there is try-catch in place for an exception, it'll be caught and handled then when the exception occurs.
But how this magic happens? How C#/compiler implements this exception handling feature at low level?
Thanks.
|
|
|
|
|
|
Don't get at all
|
|
|
|
|
Do you really want to know?
Have you read ECMA-335?
Anyway, MSIL contains high level constructs for things such as exception handling, and the JIT compiler and runtime do the actual magic. What kind of magic that is, well, I could find that out for you, but you could also mess around with some exception handling code and look at the disassembly window. The C# compiler doesn't really have anything to do with the actual implementation of the exception mechanisms, in MSIL it's still a .try block and some catch/finally/filter (can choose to have the catch ignore the exception)/fault (executes when an exception was thrown but does not catch it) blocks, no stack-walking code is generated by the C# compiler
Note: I apologize in advance for all mistakes I've made in this post
|
|
|
|
|
|
Hi all,
I have a simple serial port application in which I am listening to serial port and displaying all the data which is received to a richtextbox. My Question is;
When i build the application and run in "Debug" configuration I get "The I/O operation has been aborted because of either a thread exit or an application request " exception at serialPort.ReadExisting() transaction.
However when I build the application in "Release" Configuration I never see this exception.
In my opinion there is no reason for the exception, but unfortunately I get it in debug mode. Any ideas?
Kind Regards
zafer
|
|
|
|
|
A debug version has debug code in it. I can only assume it's interfering with your code. I've found with C# in the past I can set breakpoints in a release version.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|