|
yuenli wrote: I would like to add an event to the list view that is onSelectionChange
why you arnt using SelectedIndexChanged ? its same
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
When I try to perform the math below I get an answer of 0, but the result of the below should be 5.76
Int64 lpTotalNumberOfFreeBytes = 41085476864;
Int64 lpTotalNumberOfBytes = 712212955136;
Int64 strAnswer = ((lpTotalNumberOfFreeBytes / lpTotalNumberOfBytes) * 100);
Does anyone see what I am doing wrong here?
Thanks
|
|
|
|
|
hi,
int/int performs an integer division; you should consider one of these fixes:
- use float or double everywhere
- postpone division, hence do 100*int/int instead of int/int*100
(there is an increased risk of overflowing when doing all multiplies before all divides)
The above holds true in most programming languages (C, C++, Java, C#, ...).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
You can use float everywhere as Luc adviced you. But if you for some reason need to store lpTotalNumberOfFreeBytes and lpTotalNumberOfBytes as Int64 you can covert their values in division expression like this:
((float)lpTotalNumberOfFreeBytes / (float)lpTotalNumberOfBytes )*100;
However this expression return float value so you need to change type of strAnswer from Int64 to float or convert explicitly convert result to Int64:
Int64 strAnswer = (Int64) (((float)lpTotalNumberOfFreeBytes / (float)lpTotalNumberOfBytes )*100);
But remember if you convert float to Int64 system will cut off everything behind decimal point, so in this particular case result 5.7687068 will be converted to 5.
hth
|
|
|
|
|
Hello..
I've got an InvalidOperationException: invalid Value vor the OracleObjectMappingAttribute nNR
Could NET have a problem with casting NUMBER to int? Or have i to do something
special, because I'm using a OUT-only Parameter?
Here are my code:
PLSQL:
-------------
create type TESTOBJ as OBJECT (
nNR NUMBER;
sTEXT VARCHAR2(20);
)
create testproc(p_testobj OUT TESTOBJ)
as
v_testobj TESTOBJ := TESTOBJ(1,'Test');
begin
p_testobj := v_testobj;
end;
C# the Mapped OBj:
-------------------------------
public class OracleXTBQueueObj : IOracleCustomType
{
private int nr;
[OracleObjectMappingAttribute("nNR")]
public int NR {
get { return nr; }
set { nr = value; }
}
private string tEXT;
[OracleObjectMappingAttribute("sTEXT")]
public string TEXT
{
get { return tEXT; }
set { tEXT = value; }
}
public virtual void FromCustomObject(OracleConnection con, IntPtr pUdt)
{
OracleUdt.SetValue(con, pUdt, "nNR", this.NR);
OracleUdt.SetValue(con, pUdt, "sTEXT", this.TEXT);
}
public virtual void ToCustomObject(OracleConnection con, IntPtr pUdt)
{
this.NR = ((int)(OracleUdt.GetValue(con, pUdt, "nNR")));
this.TEXT = ((string)(OracleUdt.GetValue(con, pUdt, "sTEXT")));
}
}
C# the Factory:
-------------------------------
[OracleCustomTypeMappingAttribute("USR.TESTOBJ")]
public class OracleXTBQueueObjFactory : IOracleCustomTypeFactory
{
public IOracleCustomType CreateObject()
{
OracleXTBQueueObj obj = new OracleXTBQueueObj();
return obj;
}
}
C# the function, callin the PROCEDURE:
------------------------------------------------------------
public static void GetOO(OracleConnection conn)
{
OracleCommand cmd = new OracleCommand("UDT_TESTPROC", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
OracleParameter paramDaten = new OracleParameter("p_testobj", OracleDbType.Object, ParameterDirection.Output);
paramDaten.UdtTypeName = "USR.TESTOBJ";
cmd.Parameters.Add(paramDaten);
try { cmd.ExecuteNonQuery(); }
catch (Exception ex) //InvalidOperationException
{
Console.Out.WriteLine(ex.Message)
}
Console.In.ReadLine();
paramDaten.Value.ToString();
}
-----
Hope somebody can help me
thx in advance
faehne
|
|
|
|
|
hi there,
I am trying to make my service to insert to a database when it starts as follows :
protected override void OnStart(string[] args)<br />
{<br />
base.OnStart(args);<br />
string query;<br />
id += 1;<br />
<br />
SqlCommand comm;<br />
conn = new SqlConnection("my connection string");<br />
query = "insert into myTable values('" + id + "',lamya'" +"')";<br />
comm = new SqlCommand(query, conn);<br />
<br />
try<br />
{<br />
conn.Open();<br />
<br />
while (id >= 120)<br />
{<br />
comm.ExecuteScalar();<br />
query = "insert into myTable values('" + id + "',lamya'" + "')";<br />
comm = new SqlCommand(query, conn);<br />
id++; <br />
<br />
}<br />
conn.close();<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
}<br />
<br />
<br />
}
after adding an installer and installing the service using the Installutil.exe
when I start the service from the services manager this msg shows up:
The ServiceOnTest service on your Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the performance Logs and the Alters service.
where ServiceOnTest is the service name ,
just to know if it matters: the startup type is automatically and it run for the local System
what should I do to make it work, I need it to insert to the database and more but first I need to know what wrong I did?
Urgent help is needed , please
Thanks
There is always something to learn
|
|
|
|
|
You either have a startup error or your onstart event takes to long to complete and gets shut down.
The onstart event is only for service initialization code. You either need to spawn a worker thread at the end of onstart or have it call an exe that will perform the task you need done.
|
|
|
|
|
That may all be fine; what does the main part of the service do?
Oh, wait... this will take a long time to finish, did you mean less than?
while (id >= 120)
{
comm.ExecuteScalar();
query = "insert into myTable values('" + id + "',lamya'" + "')";
comm = new SqlCommand(query, conn);
id++;
}
|
|
|
|
|
Thanks for replying
oh yes, exactly , I meant less than ,
after correcting every thing in the code , it started ,
but I need it to open a form, when I put a statement to open a form it refuses to start , (because of the line of opening the form)
thanks again,
There is always something to learn
|
|
|
|
|
A service does not have a "desktop" to show the form on, which is why im guessing it errors. There is a setting ("Allow service to interact with desktop" ) which is part of a windows service properties which when ticked allows a service to interact with the desktop.
I have never tried showing a form or anything from a service but this may help get you on your way.
Good luck
|
|
|
|
|
Thanks for replying
s_richie wrote: There is a setting ("Allow service to interact with desktop" ) which is part of a windows service properties which when ticked allows a service to interact with the desktop.
I have looked for it, but I did not find that property , can you give me a hint from where can I tick it to allow the interaction with the desktop, please?
There is always something to learn
|
|
|
|
|
Go to your Service in Administrative tools, right click it and select Properties. On to the Logon tab there is a check box there.
Services are not "meant" to interact with the desktop they are meant to be back ground items.
|
|
|
|
|
oh! I was looking in the service properties in the C# environment,
can I make it interact with the desktop from the code itself?, so automatically being with no need to change the properties.
There is always something to learn
|
|
|
|
|
Im not sure to be honest, like I said before I have never tried to implement wgat you are asking before i was just aware of that feature on a service. Take a look through google is all i can suggest from here on.
|
|
|
|
|
thanks a lot you have done more than enough
you helped a lot
There is always something to learn
|
|
|
|
|
Knowledgestudent wrote: after correcting every thing in the code , it started ,
Glad to hear it.
Knowledgestudent wrote: open a form it refuses to start
Might it be waiting for the opened form to close?
|
|
|
|
|
Stuart Celarier of CheckFree and I explore the new languages features in C# in a series of screencasts on Channel 9. Each is a whirlwind tours of the important language features since C# 1. Stuart describes the feature and why it is useful. But he doesn't get into best practices nor suggested usages. Just the facts about the feature.
Whirlwinds are bite-sized webcasts, each is shorter than 15 minutes. You can start anywhere in the series to learn about the parts you're most interested in.
Part one of the eight-part series has been posted Whirlwind 1: What's new in C# 2 - Generics[^]
In Part 1 about generics, Stuart describes:
- What generics are.
- How generics compare with collections.
- How the compiler treats generics.
- How generics increase performance and save memory.
This feature is part of C# 2 in .NET 2.0.
The remaining seven installments will be posted to Channel 9 over the next few weeks.
|
|
|
|
|
Version 2.0 of the .NET Framework has been available now for almost 3 years.
Is this a new definition of the phrase 'new language features' that I hadn't previously been made aware of?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Nothing like keeping up with technology and giving us cutting edge information.
Can we expect to see something on LINQ around 2011?
only two letters away from being an asset
|
|
|
|
|
Hi,
I have a project mixed with C++ and C# in VS 2003.
I tried to debug into the C++ code. but it never stop at any break point.
I use CoCreateInstance to create the C++ object (C# call a c++ library #1 -- managed C++, lib #1 call CoCreateInstance to create the final object). I want to step into the function call to that object. I have the source code for all the C# and C++ projects.
I set the "Enable unmanaged debugging" to true and also "allow unsafe code blocks" to true already. but it I can debug into library 1 only!!
does any one has some idea about this!!!
Thanks a lot in advance!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Small Rat wrote: I have the source code for all the C# and C++ projects.
You have them all included and compiled in the Solution you are debugging from?
led mike
|
|
|
|
|
yes, all the projects are in the same solution. and I can compile it and run it. all the existing functions work fine. I want to add some new funcitons, so I need to debug into it!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Hi,
Problem:
I'm using C# 2005. The data type of the bitmap file saved to database is "long binary data". It should be "OLE Object".
Source Code:
Bitmap myBitmap = new Bitmap(@"c:\Picture1.bmp");<br />
OleDbConnection conn = new OleDbConnection("<<My Connection String>>");<br />
conn.Open();<br />
string sql = "UPDATE Table1 SET fldOLE = @fldOLE WHERE fldID = 5";<br />
OleDbCommand command = new OleDbCommand(sql, conn);<br />
command.Parameters.Add(new OleDbParameter("@fldOLE", myBitmap));<br />
int rowsAffected = command.ExecuteNonQuery();
Question:
How can I save Bitmap to database with data type "OLE Object"?
Thanks in advance
|
|
|
|
|
The data types of your DB are set when you create the table, not when you insert data into it. If you read here[^], you'll find how to get the info you need. If you look here[^], you'll find that this works.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Any one suggest me how to call a static method inside a class. I am having a class named as user in my project. i want to call the user type method which is declared as public static....................
In my aspx page i created an instance and trying to call the method. But it list all the method expect the method with static.
How to call it, please suggest me.
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|