|
How about...
string GetRandomString(int length)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(length);
Random rnd = new Random();
for(int i = 0; i < length; i++)
{
sb.Append((char)rnd.Next(33, 127));
}
return sb.ToString();
}
Life goes very fast. Tomorrow, today is already yesterday.
modified on Wednesday, July 15, 2009 9:08 AM
|
|
|
|
|
musefan wrote: System.Text.StringBuilder sb = new System.Text.StringBuilder(length);
ftfy.
I improved the performance a bit.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi.
this is my coding
string MyString;
MyString = "Select * from timemgmt";
if (radioin.Checked == true)
{
cn = new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=orcl;UID=it;PWD=cr;");
cmd = new OdbcCommand(MyString, cn);
cn.Open();
cmd.CommandText = "insert into timemgmt values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
cmd.ExecuteNonQuery();
cn.Close();
textbox1.text = employe ID
label19.text = System Date
label18.text = System Time
i want to do Accept employee ID in one time in a day 2nd time user give same Id in a same date not accepted
plzz give me some hints
thanks in Advance
Jawad Khatri
|
|
|
|
|
0) 'hi' = bad subject
1)
mjawadkhatri wrote: cmd.CommandText = "insert into timemgmt values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
Use parameters (odbcparameter). (read up on sql-injunctions)
2) use the 'code block' tags to post code
3) Your question: One way to do it would be to do a select from the user + date first. If the select returns 0 rows --> insert else --> don't insert
|
|
|
|
|
I can't think of any more hints, those are the ones I would have given also.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
You could try recommending a book, not the one that book stores want you to buy thou
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Nah. I only do that when a very basic question is getting asked; anyway, feel free to visit a decent book store, I could recommend the Stanford University Bookstore on the Palo Alto campus, it is quite impressive (I think it looks like an Amazon warehouse).
FYI: I added a book thread[^] on my personal CP blog for your convenience.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That's a bit far for me, but thanks none the less. I went to a book store the other day and could not even find a computer section! I'll try a different one next time...
Some good advise in your thread
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
musefan wrote: That's a bit far for me
Same here, but I do visit it on every opportunity, which is once in ten years or so.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Well I shall keep it in mind if I am ever in the area
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Well for once I was first
|
|
|
|
|
I love when they post code that is a disaster, we try to help, and they never answer anyone who replies.
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.
|
|
|
|
|
Christian Graus wrote: we try to help, and they never answer anyone who replies.
I know
I think in all the answers I gave to questions (which is compared to you almost nothing but hey I try ) I might have gotten an answer back like twice or so.
|
|
|
|
|
Smart people walk away from disasters, for some reason we feel attracted to them??
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
It's the same as seeing an accident on the road.
For some reason you can't resist to look.
|
|
|
|
|
Hi All,
I have to develop an application using C#. Application requirements is given below:
1.Automatically send job alerts to all the registered job seekers based on some criteria like
work experience,Skills etc.
2.There are about 9 lac registered users and will increase in future.
3.Once the application started will send email to all the users and after completing the
email sending to all users it will stop/pause for some time say 3 hours and after that
it will automatically started . This process will keep on repeating until administrator
stop the application.
4.Application will run on the same server where database is running.
Please suggest me how to develop the application so that it consume minimum resources of the server?
Should I develop an application or a windows service? Which will be the best solution?
Please give suggestion keeping in mind that server resources should be consumed minimum?
Please Help.
Thanks & Regards,
Dev
|
|
|
|
|
dev sheoran wrote: windows service
Yes
only two letters away from being an asset
|
|
|
|
|
Need to speed up my typing speed
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Mark Nischalke wrote: dev sheoran wrote:
windows service
Yes
No, I wont do that.
I'll need to keep polling for checking when to start the next batch as he wants to do this every 3 hrs.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Manas Bhardwaj wrote: I'll need to keep polling
Ever heard of a timer?
only two letters away from being an asset
|
|
|
|
|
I am new to C# and never developed a windows service.Please give any reference to the windows service which send emails. It will be help full for me.
Thanks,
Dev
|
|
|
|
|
You're asking for the source code to your project ? How about you buy some books, or use google, or even search this site for articles ?
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.
|
|
|
|
|
You could create a Console Application which can be scheduled to run after every 3 hours. Admin may disable the task if he wants.
You need to come up with a logic which will get the users to whom you want send the email. This will be a stored procedure returing you the user details and probably also the email content.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
1)I don't want to run this application after every 3 hours. I want that application stop/pause for 3 hours after sending emails to all users and after that it starts automatically.
2) Its not necessary that it take same time to send emails to all users. Time to complete the process by the application may change as it depends on availability of system resources and on some others factors too.
Thanks,
|
|
|
|
|
Hi,
When trying to run a vb script on a machine, this is what it gives as error:
Can't find script engine \"VBScript\"
So to fix this I logged into the machine and did the following to install the vbscript engine:
in run window
regsvr32 vbscript
Message was that installation succeeded.
Then tried running the script on the machine again and still gives the same error as before.
Any thoughts please?
Thanks
|
|
|
|