|
My apologies, I didn't mean to refer to a CASE statement. What you're looking for is a simpeler IF statement;
DECLARE @operator BIT;
SET @operator = 1;
IF @operator = 1 THEN
BEGIN
SELECT DISTINCT
T.TICKET_NUMBER AS TicketNum,
A.DESCRIPTION AS Action,
O.SYMBOL_CODE AS Symbol,
T.TRADE_PRICE AS Price,
T.VOLUME_TRADED AS FillVol,
T.EXTENDED_PRICE AS TotalValue,
T.SUBMITTED_TIME AS ActTime,
T.SUBMITTED_DATE AS TransDate
FROM TSDETL AS T
INNER JOIN TSORDR
AS O ON O.SUBMITTED_DATE = T.SUBMITTED_DATE
AND O.TICKET_NUMBER = T.TICKET_NUMBER
INNER JOIN TSORDA
AS A ON O.ORDER_ACTION = A.ACTION_CODE
WHERE (T.SUBMITTED_DATE = @SUBMIT_DATE)
AND (T.VOLUME_TRADED >= @Volume)
AND (T.TICKET_NUMBER IS NOT NULL)
AND (O.SYMBOL_CODE= @Symbol)
ORDER BY ActTime DESC
END
ELSE
BEGIN
SELECT DISTINCT
T.TICKET_NUMBER AS TicketNum,
A.DESCRIPTION AS Action,
O.SYMBOL_CODE AS Symbol,
T.TRADE_PRICE AS Price,
T.VOLUME_TRADED AS FillVol,
T.EXTENDED_PRICE AS TotalValue,
T.SUBMITTED_TIME AS ActTime,
T.SUBMITTED_DATE AS TransDate
FROM TSDETL AS T
INNER JOIN TSORDR
AS O ON O.SUBMITTED_DATE = T.SUBMITTED_DATE
AND O.TICKET_NUMBER = T.TICKET_NUMBER
INNER JOIN TSORDA
AS A ON O.ORDER_ACTION = A.ACTION_CODE
WHERE (T.SUBMITTED_DATE = @SUBMIT_DATE)
AND (T.VOLUME_TRADED <= @Volume)
AND (T.TICKET_NUMBER IS NOT NULL)
AND (O.SYMBOL_CODE= @Symbol)
ORDER BY ActTime DESC
END You can make this stored procedure even simpeler by splitting the query into;
* a view that does the selection of the fields and the joins
* put the filter- and order-statements in a select-query that you run against the aforementioned view
I hope this helps
I are troll
|
|
|
|
|
|
An object reference is required for the non-static field, method, or property
WTH does it want from me!??
namespace WindowsFormsApplication3
{
class Class1
{
public String astring;
public static void asdf()
{
String anotherstring;
astring = anotherstring; //It doesn't like this
}
}
}
I searched and found so many 1000s of similar problems but I couldn't figure out what I'm supose to do to fix it.... maybe 'cause I'm to tired to figure it out but there is nothing wrong with that program!
I want astring to be where it is and access from inside another function. Why can't I do this?
|
|
|
|
|
The astring-field is not static, but your method asdf() is. So you can't access the field within a static context.
Try to rewrite it like this:
public static void asdf() {
String anotherstring;
Class1 myObject = new Class1();
myObject.astring = anotherstring;
}
or like this:
public void asdf() {
...
}
Regards
Sebastian
|
|
|
|
|
namespace WindowsFormsApplication3
{
class Class1
{
public String astring;
public static void asdf()
{
String anotherstring;
astring = anotherstring;
}
}
}
Because you have declared astring with "public String astring" within your class body, it only exists when you have an instance of the class "Class1".
Because you have declared asdf() as "public static void asfd()" it is a static method - i.e. can be used by "Class1.asdf()" rather than via an instance as shown below:
Class1 c = new Classs1();
c.asfd();
When you execute asdf() as a static method, there is no "this" instance for the astring reference to attach to!
Either, make the astring definition static, or remove the static declaration from the asdf() definition, depending on how you want to use the method / sting.
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
|
|
|
|
|
Ok thanks guys
I'm still not sure I quite understand what the hell static is doing, but dropping it doesn't seem to have affected anything else in my program (The above was just a sample so I didn't have to post 1000s of lines)
Thanks again for the quick reply. I was getting ready to start breaking stuff... you guys have probably saved my monitor lol.
|
|
|
|
|
What does static do? Well, it is kinda important.
If you define the following:
public class Demo
{
public static string s1 = "Hello";
public string s2 = "Goodbye";
}
When you define a class, only the parts of the definition that are marked as static exist. So, if your code consists of:
static void Main()
{
Console.WriteLine(Demo.s1);
}
then it works, because s1 always exists as part of the Demo class.
But you can't have:
static void Main()
{
Console.WriteLine(Demo.s2);
}
because s2 only exists when you create an instance of the Demo class. Thus:
static void Main()
{
Demo d = new Demo();
Console.WriteLine(d.s2);
}
Will work. "d" is given a new instance of the Demo class, and so it has a "s2". If you create a second instance of Demo
Demo d2 = new Demo();
then d2.s2 will also exist, but this does not have to be the same as d.s2 They are separate instances.
Try to think of it this way: you can have two instances of a car - your car, and my car - and they are separate. If I crash my car into a tree, it does not affect your car. If neither of us have a car, then Ford (the car manufacturer) still exists.
"Ford" is static, it exists with or without an instance of car, but to get to the shops, I must have an instance of car for myself.
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
|
|
|
|
|
Ahh ok that makes sense now.
I think it was just the error message that was driving me insane.
It's terriable... I'm so good at writing programs and have been doing it for years, but still don't know the 'basics' lol
|
|
|
|
|
No problem - I know the feeling well!
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
|
|
|
|
|
Hi all,
i want to know how to fire enter key press in the textbox to log into next form or to move fouce on the button
Thanks
|
|
|
|
|
Just use the event "KeyPress" or "KeyDown". Check if key pressed is "Enter".
If "Enter" pressed, then button.Focus(); or go to next form.
|
|
|
|
|
Use something like this....
private void Textbox__KeyDown( object sender_, KeyEventArgs args_ )
{
if ( args_.KeyCode == Keys.Return )
{
// Do whatever
}
}
|
|
|
|
|
|
Hi All,
I have tables called CALL and Operator.
Select Distinct(Mobile),MIN(DATE_OF_CALL),NAME_OPERATOR from Call inner Join Operator on
Call.CustomerId=Operator.CustomerID
where Datename(month,DATE_OF_CALL)='APRIL'
Group by Mobile
What i want is to get the first date of entry for each Mobiles in the month of april and the operator who attended them.
However i Have to group by Name_operator to run the above script.But i dont want them to be grouped by OPerator.I want the first entry of a mobile in the database together with the name of the operator who attended them.
How do i go about it Please?
Thank you so much.
|
|
|
|
|
Do NOT cross post, you were right with the database forum - cross posting to here is RUDE!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How can i select all the items in list box by pressing Ctrl+A
i wrote the code to accept keys but i don't know how to highlite all the item in list view.
if(e.Control == true & e.KeyCode == Keys.A)
{
listView1.....??????
}
A S E L A
|
|
|
|
|
You can add to the SelectedItems collection.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
for(int i = 0; i < listView1.items.count; i++)
listView1.setSelected(i,true);
Use the above loop to select each item.
|
|
|
|
|
hey,
i have two treeview controls and whenever i try to drag a node that has children under it to the other treeview it only drags that node without its children.
Any ideas how to solve this?
am using drag and drop
thank u
|
|
|
|
|
try this[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i did that and didnt find anything useful.. otherwise i wudnt post my question.. if u dont wana help just dont reply
|
|
|
|
|
Did you look at the first hit on the list - a complete method for drag/drop between trees. What do you expect from the forums.
I actually tried the search, recognised some of the links that I used when playing with this when I moved from VB to C# recently and figured it was an excellent place to start. If you cannot get anything useful from that list then you have my sincere sympathies as you must be in the wrong career.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
well if ud read my first post ud see that it does work the whole drag nd drop, its just tht i found a bug that it doesnt take the underlying nodes with.
there is nothing wrong with asking for help. it can turn out be timesaving when u dont have a lot of it.
|
|
|
|
|
Well, it sounds like your code doesn't go into the child nodes of the dragged node and moves them as well. So far, your code only moves the one node.
|
|
|
|
|
I want to store dynamic variables in a exe file (C#), that I can access [mostly just strings] to read or write. I was using the Application Settings class but it apparently saves the files in Application Data but I want my exe to take the values from the form and write them to itself or store them inside the executable file so that when I send the file to someone else it will have the preferences stored without having to do anything.
If this is not possible is there any way of making a C# builder application that will ask for variables and then create a new exe file with the variables pre-stored? Thanks
|
|
|
|