|
I'm in need of creating 200 bool random value (0 & 1). I'm coding like this :
Random rand = new Random()
rand.Next(0,2)
If i run in debug mode, the values it create is really random but if i don't debug, let it run automatic, all the values is just 0 or 1. Can someone tell me why and give me the direction to solve it?
Thanks!
|
|
|
|
|
If you look closely at the documentation for the Random class, you will see that it doesn't work when calls to Next are made in quick succession. That explains your debug vs non-debug behavior.
Instead of generating a random number between 0 and 2, wouldn't it be better if you generated random numbers (0 to size of int) and then converted them to binary? You can generate as many random numbers as you want until you get 200 binary digits.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks! Your direction really works!
|
|
|
|
|
I have a decimal value 23.25 . When i use the math.round(23.25,1) in VS.NET, the result is 23.2 but with the function: round(23.25,1) in SQL Server 2000, the result is 23.3
How can i let them return the same value ?
Thanks!
|
|
|
|
|
See reply in the other forum you posted to (SQL/ADO/ADO.NET).
BTW posting the same question to multiple forms is considered to be rude, and will in some cases result in your question being ignored in all places.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
I'm really sorry, Graham! I didn't mean it. Because i don't know which forum the question is suit to ... Besides, i used to face a similar situation. I used to posted a question in C# general but no-one answer me because posting it in SQL is more exactly ... So ... I'm really sorry. I will never repeat it again.
By the way, thanks your reply!
|
|
|
|
|
I host a object in a window service, and call it remotely from a particular client. I set the object as a Singleton mode in which it should return the same instance everytimes i remotely call. However, it happens to me that at some point, it will create a new instance of the object ???!!!!
What went wrong ?!!
|
|
|
|
|
Maybe the singleton's lease expired and the remoting framework created a new one?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
hi,
i have two listview controls , i want columnheader width change in one of the control should be similaraly affected in the other control at run time......
waiting 4 reply
zeshan
|
|
|
|
|
Well, just set the width of the columnheader of the second control to that of the first control. Hope that helps.
Darth_Sulfur (Sulfurik)
http://www.SulfurSoft.tk
ftp://tsfc.ath.cx
http://tsfc.ath.cx
hotline://tsfc.ath.cx
|
|
|
|
|
I'm using this SQL SELECT statement:
int surveyNo
sqlTotal= string.Format("SELECT COUNT(survey{0}) FROM ResultsTbl WHERE survey{0}<>0", surveyNo);
I know the syntax is wrong in the parentheses after the COUNT. How do I fix this syntax, to put the variable value in?
sea#
|
|
|
|
|
First, you should be using parameterized queries to do this.
Your SQL statement should look like this:
SELECT COUNT survey FROM ResultsTbl WHERE survey = @surveyNum
The @surveyNum is a placeholder for a SQL parameter. More information can be found in this[^] article by Colin Angus Mackay.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need to bring the column no. as parameter. The table has 4 columns: username, survey1, survey2, survey3. SrNo is an int variable the method get. I want to find out How do take this SrNo and "glue" it with survey
This is what I got from the article
sqlTotal= "SELECT COUNT(survey@SrNo) FROM ResultsTbl "+<br />
"WHERE survey@SrNo<>0";<br />
cmdTotal.Parameters.Add("0", survey@SrNo);
not to sue about survey@SrNo syntax. Got error in
cmdTotal.Parameters.Add("0", survey@SrNo);
under survey@SrNo.
sea#
|
|
|
|
|
sea# wrote:
sqlTotal= "SELECT COUNT(survey@SrNo) FROM ResultsTbl "+
"WHERE survey@SrNo<>0";
cmdTotal.Parameters.Add("0", survey@SrNo);
Parameters don't work that way.
I don't know what your trying to return and I don't know what the conditions are. You need to explain how the data is setup in your table and what you want to accomplish.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This is my full method:
public void CalcResults(int SrNo, out int total, out int Ans1, out int Ans2, out int Ans3)
{
string sqlTotal;
string sqlAns1;
string sqlAns2;
string sqlAns3;
if (SrNo>=1 & SrNo<=3)
{
sqlTotal= string.Format("SELECT COUNT(survey2) FROM ResultsTbl WHERE survey{0}<>0",SrNo);
sqlAns1= string.Format("SELECT COUNT(survey2) FROM ResultsTbl WHERE survey{0}=1",SrNo);
sqlAns2= string.Format("SELECT COUNT(survey2) FROM ResultsTbl WHERE survey{0}=2",SrNo);
sqlAns3= string.Format("SELECT COUNT(survey2) FROM ResultsTbl WHERE survey{0}=3",SrNo);
}
else
sqlAns1=sqlAns2=sqlAns3=sqlTotal="No answer was chosen";
OleDbCommand cmdTotal = new OleDbCommand(sqlAns1, cnSurvey);
OleDbCommand cmdAns1=new OleDbCommand();
OleDbCommand cmdAns2=new OleDbCommand();
OleDbCommand cmdAns3=new OleDbCommand();
cmdTotal.Connection = cnSurvey;
cmdTotal.CommandType = CommandType.Text;
cmdTotal.CommandText = sqlTotal;
cmdAns1.Connection = cnSurvey;
cmdAns1.CommandType = CommandType.Text;
cmdAns1.CommandText = sqlAns1;
cmdAns2.Connection = cnSurvey;
cmdAns2.CommandType = CommandType.Text;
cmdAns2.CommandText = sqlAns2;
cmdAns3.Connection = cnSurvey;
cmdAns3.CommandType = CommandType.Text;
cmdAns3.CommandText = sqlAns3;
cnSurvey.Open();
total = int.Parse(cmdTotal.ExecuteScalar().ToString());
Ans1 = int.Parse(cmdAns1.ExecuteScalar().ToString());
Ans2 = int.Parse(cmdAns2.ExecuteScalar().ToString());
Ans3 = int.Parse(cmdAns3.ExecuteScalar().ToString());
cnSurvey.Close();
}
The data is table like:
username | survey1 | survey2 | survey3
-----------------------------------------------
sea# | 1 | 3 | 2
These are answers of a user to a survey. I need to collect all results from all users +total, so I can calculate statistics on it etc.
TIA,
sea#
|
|
|
|
|
Hi
My computer has Two lan connection and ONe is conneted through modem.
I am able to find out the only one Lan connection(Ethernet Lan Card) (This setting is retrieved from the registry) and Modem connection is also showing on Winform.
But i am not able to identify Blue Tooth Lan Connection Where it stores inside the registry if Blue tooth lan connection is connected.
I have winform and List box and one button When i press the button it displays all the avaliable Lan and modem and blue tooth lan connection of local host displays inside the list box.
I am able to retrive only two connection right now (Ethernet Lan card and one modem through) but i am not able to identify Bluet tooth connection
Can anoy body tell me how will identify
thanks
sanjeev
|
|
|
|
|
I have a method in a class that updates an xml file based on an input parameter which is a DataTable.
To update my xml file I use the DataTable methods
<br />
GetChanges(DataRowState.Modified)<br />
GetChanges(DataRowState.Added)<br />
GetChanges(DataRowState.Deleted)<br />
The problem is that when I call GetChanges(DataRowState.Deleted) I do get a datatable of the rows that were deleted but all I can access is the number of rows but not the row contents so I can't figure out which rows were deleted.
Any help appreciated in advance.
|
|
|
|
|
|
The only way I could think of doing it is by having a method that when called to set a row color, the method loops through each item in that row and sets the color.
|
|
|
|
|
hi,
i want to use a custom action in my deployment project conditionaly but it does not work even when i use the custom action unconditionaly,
let me know how to activate the custom action?
thanks
|
|
|
|
|
I am trying to load an rtf file which is created by using Wordpad into a richtextbox. However, the text seems lost some of its format information, e.g. text set to bold and different sizes, after been loaded into the richtextbox. How can I add these texts while retaining their format properties?
|
|
|
|
|
The RTB control doesn't support all of the formatting that Wordpad or Word saves into their RTF files.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
OK, I have 2 questions about this function:
1. Why does this function stop working? On one machine (WinXP), this happened already, it won't beep. On another computer (WinXP also), it beeped fine until today that I loaded my project and tried it... I put that same project on another computer (Win2k) and it worked fine, so I grabbed its Kernel32.dll, renamed it, and then put it on the second PC I listed, but the program crashes, it returns to VS.NET without any exception message and then it puts the cursot on the "public static extern bool Beep();" line... How can I fix this? I really need this function!
2. I used to code in a Windows scripting language that did all the datatype conversion stuff for you (http://www.autoitscript.com), and when I called the Beep function with decimal parameters, it worked, but when I try floats, doubles, and decimals in C# it doesn't beep!
If anyone can help, I'd be thankful for life! Thanks!
Darth_Sulfur (Sulfurik)
http://www.SulfurSoft.tk
ftp://tsfc.ath.cx
http://tsfc.ath.cx
hotline://tsfc.ath.cx
|
|
|
|
|
Is the PC speaker enabled? (Bios and Control panel) Does it work?
(Sometimes it really is a hardware problem )
BTW, copying Kernel32.dll from one OS to another really is a bad idea...
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
I agree with Ron. Either you've got a hardware problem, or someone turned the volumn down on the speakers or in the Sound control panel or the little Volume slider, or muted either.
And yeah, copying Kernel32.dll from another machine is a REALLY bad idea. If you replaced with one in System32, it's amazing your machine even booted!
BTW: Beep takes two parameters: unsigned integers, NOT floats, doubles, decimals, ... floating point numbers will not work. The proper DllImport should look like this:
static extern bool Beep(uint dwFreq, uint dwDuration);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|