|
Hi,
I think this might help you: Simple Windows Service Example[^]
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
it is most like the same procedures i had did
|
|
|
|
|
|
I use the [System.Timers.Timer] object in my Windows Services: -
System.Timers.Timer t;
void OnStart(string[] args)
{
t = new System.Timers.Timer();
t.Interval = 1000;
t.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed);
t.Enabled = true;
}
void t_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
...
}
|
|
|
|
|
Good day
How do i find every occurence of a substring that begin with a specefied set of characters and end with another set of characters eg
string str = "src=test.pgn testing sub src=file.pgn find it"
i want to read strings that start with src and end with .pgn in the above example i want the following strings in an array "src=test.pgn" and src=file.pgn
Thank you
|
|
|
|
|
|
why are regular expressions so difficult to understand???????
|
|
|
|
|
Don't worry, most people hate them too. I rarely use them, and always have to go back to the manual to check things when I need to.
Post what your trying (in a new question) and maybe some reg-ex superhero can help.
http://xkcd.com/208/[^]
Simon
|
|
|
|
|
|
Hi,
I have problem in keeping the selected text highlighted in a richtextbox when the mouse clicked to other control, eg changing font from a list box or clicking on a treeview control. The text is still selected but the the text not highlighted. How can I maintain the text selection highlighted?
Can someone help?
Regards,
WingOnn
|
|
|
|
|
Set the "HideSelection" property on the text box to false.
Simon
|
|
|
|
|
Simon,
Thanks. I overlooked this property.
Regard,
Wing Onn
|
|
|
|
|
|
I have two user tables in an existing SQL database. One contains only u_id(int) not null and the other contains userid(int) not null, username and so on. I am trying to insert new users in this table but I am getting Sql exception error. I am looking for a function which increments the uid and userid in both tables. I dont know how to go about it.
Regards,
Pradeep
|
|
|
|
|
You could redefine the columns to be automatically incrementing numbers. You use the "IDENTITY(x,y)" command when defining the table. (x = start, y = increment value).
e.g.
CREATE TABLE TableName
(UserId INT IDENTITY(1,1) NOT NULL,
UserName VARCHAR(50) NOT NULL,
Password VARCHAR(50) NOT NULL)
(Or using the GUI, you can set the Identity Specification property of the column to yes, and set the seed and increment there).
Personally though, using an autonumber as the primary key for a user isn't a very good design. Instead, I would define the primary key of a user as a "uniqueidenitifer" type (in SQL) and use guids in C#. Then, when you need to create a new user, you can call Guid.NewGuid() to create a new guid value that you use for that user.
Good luck.
Simon
|
|
|
|
|
Thanks Simon, what if i am not allowed to change the design , since the system is already in place. I have to make a new system from scratch which will use the existing user table to give the roles and access. Is there a way to append the new user id by 1 in both tables..
|
|
|
|
|
Complain to management that the DBA is not doing or capable of doing his job properly.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Haha. Yeah, actually ignore my answer, just do this.
Simon
|
|
|
|
|
Ahh. Well in that case there is no easy way.
Are you sure you can't change the column properties. You should be able to modify it even if the database is already live.
If not, first you'll have to do a select statement to find out what the existing maximum value is (There is a command[^] specifically to do this)
Then you'll have to increment it, and include it when you insert the new user.
If multiple people/programs can be accessing your database at the same time, be careful to check you program correctly handles the situation where 2 people both try and insert a user at the same time. You'll get a duplicate insert exception on the second one, so you will need to handle that and try again. Or take a lock of some kind.
Simon
|
|
|
|
|
Having read the other posts and your replies, what you need to do is:
- open a transaction
- select the max u_id value plus one
- insert to both your tables
- commit the transaction.
This should ensure no duplication.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I'll admit I'm no SQL expert, but I don't think that opening a transaction will always ensure you don't get duplicate inserts in this case. All a transaction does is group the statements so you can ensure either all are executed (and a commit occurs) or none are executed (and a rollback occurs).
It is down to the isolation level settings[^] on the server to control what kind of locking takes place during a transaction.
The default (READ COMMITTED) allows other transactions to modify data in between statements in a transaction. Thus 2 transactions could both read the current max id (e.g. 5), both could then attempt an insert. The first would successful insert, the second would block. the first would then commit, which would allow the second to perform it's insert, which would cause a duplicate insert exception.
(I could be wrong about this, perhaps someone could explain if I have misunderstood the meaning of transaction isolation level)
Simon
|
|
|
|
|
Probably didn't explain it too well.
- begin tran
- update u_id table set u_id = u_id (does nothing except locks the table)
- select Max(u_id + 1)
- insert to both tables
- commit tran
While the u_id table is locked nobody else can update it.
So its not really the isolation level, it's my lack of explanation
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ahh, yes, I see what your talking about now.
Simon
|
|
|
|
|
A better explanation always helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Some people have got you on the right lines. The standard way to do this horrible hack, is to have a separate table that contains a row for the table you want to update. This row normally consists of a table name, and a sequence number.
In your code, you start a transaction, then you update the row to be row + 1. Next, select the same row - as you've updated it, you have the lock on the row. If somebody else tries to perform this operation, you have the row locked. Commit the transaction, and you have a new unique sequence.
|
|
|
|