Click here to Skip to main content
15,895,462 members
Home / Discussions / C#
   

C#

 
GeneralReading all IP add in Local network Pin
sreejith ss nair17-Apr-04 23:15
sreejith ss nair17-Apr-04 23:15 
GeneralRe: Reading all IP add in Local network Pin
leppie18-Apr-04 0:49
leppie18-Apr-04 0:49 
GeneralRe: Reading all IP add in Local network Pin
Anonymous18-Apr-04 3:11
Anonymous18-Apr-04 3:11 
GeneralRe: Reading all IP add in Local network Pin
Dave Kreskowiak18-Apr-04 4:47
mveDave Kreskowiak18-Apr-04 4:47 
Generallocking problem in continous insert Pin
dabuskol17-Apr-04 22:19
dabuskol17-Apr-04 22:19 
GeneralRe: locking problem in continous insert Pin
leppie17-Apr-04 22:59
leppie17-Apr-04 22:59 
GeneralRe: locking problem in continous insert Pin
Heath Stewart19-Apr-04 2:51
protectorHeath Stewart19-Apr-04 2:51 
GeneralRe: locking problem in continous insert Pin
dabuskol19-Apr-04 18:58
dabuskol19-Apr-04 18:58 
Health,

Thank you, I got your point. That's why i'm having messages that connection is already open even though I already closed it or the other way.

Anyway, Thank guys for all your help. I was able to fix my problem by using the Monitor class. It's under System.Threading. I locked the connection before executing the insert statement and then unlock unlock it once it's done. In that case the succeeding insert will not be able to get the 1st connection until it's release.

for other guys who will have the same problem.
CODE:

DBCommand = new SqlCommand(strInsert,DBConnect);
Monitor.Enter(DBConnect);
try
{
if (DBConnect.State.ToString() == "Closed")
{
DBConnect.Open();
}
DBCommand.ExecuteNonQuery();
DBCommand.Connection.Close();
DBConnect.Close();
Monitor.Exit(DBConnect);
}
catch (Exception objerr)
{
System.Diagnostics.EventLog.WriteEntry("ossrop", "Insert Failed : " + objerr.Message);
}

PS: If you have comments with my solution, feel free to modify it so that other people whill read this email in the future will get the correct solution.
GeneralRe: locking problem in continous insert Pin
Heath Stewart20-Apr-04 3:21
protectorHeath Stewart20-Apr-04 3:21 
Questionhow to convert HANDLE type in C#??? Pin
Paolo Ponzano17-Apr-04 21:04
Paolo Ponzano17-Apr-04 21:04 
AnswerRe: how to convert HANDLE type in C#??? Pin
leppie17-Apr-04 21:09
leppie17-Apr-04 21:09 
GeneralRe: how to convert HANDLE type in C#??? Pin
Paolo Ponzano17-Apr-04 21:27
Paolo Ponzano17-Apr-04 21:27 
GeneralSetup project problem Pin
Small Rat17-Apr-04 9:28
Small Rat17-Apr-04 9:28 
GeneralRe: Setup project problem Pin
Mazdak17-Apr-04 23:08
Mazdak17-Apr-04 23:08 
GeneralRe: Setup project problem Pin
Mazdak17-Apr-04 23:40
Mazdak17-Apr-04 23:40 
GeneralRe: Setup project problem Pin
Small Rat18-Apr-04 17:15
Small Rat18-Apr-04 17:15 
GeneralRe: Setup project problem Pin
Heath Stewart19-Apr-04 2:58
protectorHeath Stewart19-Apr-04 2:58 
GeneralC# Custom control property options Pin
mattd8917-Apr-04 8:00
mattd8917-Apr-04 8:00 
GeneralRe: C# Custom control property options Pin
leppie17-Apr-04 21:13
leppie17-Apr-04 21:13 
GeneralReading the serial number Pin
Amirjalaly17-Apr-04 7:27
Amirjalaly17-Apr-04 7:27 
GeneralRe: Reading the serial number Pin
Mazdak17-Apr-04 8:36
Mazdak17-Apr-04 8:36 
Generalconecting with modem Pin
Amirjalaly17-Apr-04 6:42
Amirjalaly17-Apr-04 6:42 
Generalconnecting with modem Pin
Amirjalaly17-Apr-04 6:36
Amirjalaly17-Apr-04 6:36 
Generaldatagrid question Pin
hfuiew17-Apr-04 5:26
hfuiew17-Apr-04 5:26 
GeneralRe: datagrid question Pin
Bitwise Gamgee19-Apr-04 4:22
Bitwise Gamgee19-Apr-04 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.