|
What's wrong with Thread.Sleep?
How about this (untested code):
DateTime start = DateTime.Now;
TimeSpan ts = DateTime.Now - start;
while (ts.TotalMilliseconds < 500)
{
ts = DateTime.Now - start;
}
But that would be silly. Use Thread.Sleep.
|
|
|
|
|
Thread.Sleep(500) has only effect on the current thread.
It doesn't have any effect on the other threads.
|
|
|
|
|
string query = "Insert Into Users(username,password) values(' + "\"" txtusername.Text "\" ','"\" txtpassword.Text"\"')";
adp1 = new OleDbDataAdapter(query, conn); > firstly, is this correct ?
secondly: how should i change this values(' + "\"" txtusername.Text "\" ','"\" txtpassword.Text"\"') ? it gives error ;( dont know how to modify ?
|
|
|
|
|
string query = "Insert Into Users(username,password) values('" + txtusername.Text +"','"+ txtpassword.Text+"')";
|
|
|
|
|
Message Closed
modified 27-Apr-15 10:59am.
|
|
|
|
|
string baglan = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source=veritabani.mdb";<br />
conn = new OleDbConnection(baglan);<br />
conn.Open();<br />
string query = "Insert Into Users(username,password) values('" + txtusername.Text +"','"+ txtpassword.Text+"')";<br />
OleDbDataAdapter da = new OleDbDataAdapter(query ,conn );<br />
DataSet ds = new DataSet();<br />
da.Fill(ds);<br />
conn.Close();<br />
|
|
|
|
|
Message Closed
modified 27-Apr-15 10:59am.
|
|
|
|
|
Once you get it working you really should make a method to go through the textboxes and strip out some characters. Right now you are vulnerable to a sql injection attack.
If I put: bob'; delete * from user; --
I just deleted everything in the user table.
|
|
|
|
|
eggsovereasy wrote: Once you get it working you really should make a method to go through the textboxes and strip out some characters.
You should never strip out and limit the user´s possibilities. You should escape the characters instead.
|
|
|
|
|
Hi,
Does anybody know how to calculate/extract the Pitch values from a Wave (*.wav) file?
Thanks,
Gidon
|
|
|
|
|
Hi!
For this you'll have to perform a fourier transformation.
Basically, your try to approximate the wave form you have by adding many sinus waves. That way you get the volume (amplitude) at certain frequencies, which will ultimately give you the pitch.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Thanks for the explanation.
|
|
|
|
|
Hi ,
I succeeded in performing the FFT on my wave file and even printed the results into a nice Spectogram.
But I don't know how to extract the pitch from these values. Do you have any pointers at to what function I need to perform on the FFT data?
Thanks
Gidon
|
|
|
|
|
Hi!
I'm afraid I don't have any further pointers on how to calculate the pitch value.
You should be able to get a pitch value by multipyling each frequency with the amplitude for this frequency and summing up the values.
That way you'd get a high value if you have many loud, high-frequency bands and a low value if there are more low-frequency bands.
But I must admit I don't know if that'll suite your needs.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Dear All,
How do i findout list of all the SQLServer Names or Data Sources in a domain ?
Please send me the code if anybody have
Urgent from Shiv
With Regards,
Siva
|
|
|
|
|
Hi all
How i can to get access to default value or MinValue of an system type.
Or constuct byself an MinValue (or default value) value for each type.
I understand this is possible to make with switch\case but i wont know is exist more convinet way.In run time.
Exmpl:
<br />
<br />
object GetDefaultValue(object SysTypeValue)<br />
{<br />
object defVal;<br />
<br />
......<br />
<br />
return defVal;<br />
}<br />
<br />
void Main()<br />
{<br />
System.Date dt = System.Date.Now();<br />
int i = 100;<br />
char c = 'a';<br />
byte b = 8;<br />
<br />
System.Console.WriteLine(GetDefaultValue(i).ToString());<br />
System.Console.WriteLine(GetDefaultValue(c).ToString());<br />
System.Console.WriteLine(GetDefaultValue(b).ToString());<br />
System.Console.WriteLine(GetDefaultValue(dt).ToString());<br />
<br />
<br />
}<br />
<br />
console:
0
0
0
01.01.0001 0:00:00
THANK
|
|
|
|
|
Not sure if the following works, but it should create an instance of passed type by using its default constructor.
object GetDefaultValue(object SysTypeValue)
{
return Activator.CreateInstance(SysTypeValue.GetType());
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
Hi,
i want to check the existence of an integer value in the textbox control with the following code:
if (Convert.ToInt16(tbStockTypeId.Text) <= 0)
works fine when an intger value is entered. but when i enter 'abc' it raises FormatException "Input string was not in a correct format."
Need help for its correction.
With Thanx
|
|
|
|
|
First check if the Text value is numeric before trying to convert it.
This can be done with a RegEx , or Char.IsNumeric
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
thanks for reply! J4amieC
Char.IsNumeric
is fine for a character, while i'm working with textbox string.
uroojkhan
|
|
|
|
|
try{<br />
int stocktype = Convert.ToInt16(tbStockTypeId.Text);<br />
if(stocktype <= 0) { <br />
}<br />
}<br />
catch(FormatException fexc){<br />
Messagebox(tbStockTypeId.Text + "Is not a number");<br />
}
Coulda, woulda, shoulda doesn't matter if you don't.
[MODIFIED]In this 32 bit world, use ToInt32 unless you have little memory.[/MODIFIED]
<marquee>
-- modified at 10:53 Friday 26th May, 2006
|
|
|
|
|
Although that would work absolutely fine, its generally considered bad practice to control program flow with exceptions.
Exceptions for exceptional behaviour - the user making an invalid entry is not exceptional, it is expected!
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
J4amieC wrote: the user making an invalid entry is not exceptional, it is expected
He he , I agree on this, but I don't understand why using try/catch is bad practice?
Coulda, woulda, shoulda doesn't matter if you don't.
<marquee>
|
|
|
|
|
I guess because throwing exceptions is just more resource intensive, its a lot quicker to first check if the value is valid.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
mja, sounds reasonable.
tnx.
Coulda, woulda, shoulda doesn't matter if you don't.
<marquee>
|
|
|
|