Click here to Skip to main content
15,906,569 members
Home / Discussions / C#
   

C#

 
GeneralRe: Small Dialogs - How Small Can I Go ?? Pin
iltallman7-Feb-11 12:31
iltallman7-Feb-11 12:31 
AnswerRe: Small Dialogs - How Small Can I Go ?? Pin
#realJSOP7-Feb-11 2:33
professional#realJSOP7-Feb-11 2:33 
QuestionC# Object reference not set to an instance of an object Pin
LAPEC6-Feb-11 8:45
LAPEC6-Feb-11 8:45 
AnswerRe: C# Object reference not set to an instance of an object Pin
fjdiewornncalwe6-Feb-11 8:56
professionalfjdiewornncalwe6-Feb-11 8:56 
GeneralRe: C# Object reference not set to an instance of an object Pin
LAPEC6-Feb-11 10:31
LAPEC6-Feb-11 10:31 
GeneralRe: C# Object reference not set to an instance of an object Pin
RobCroll7-Feb-11 2:12
RobCroll7-Feb-11 2:12 
GeneralRe: C# Object reference not set to an instance of an object Pin
Rob Philpott7-Feb-11 3:51
Rob Philpott7-Feb-11 3:51 
AnswerRe: C# Object reference not set to an instance of an object Pin
Luc Pattyn6-Feb-11 9:15
sitebuilderLuc Pattyn6-Feb-11 9:15 
AnswerRe: C# Object reference not set to an instance of an object Pin
dan!sh 6-Feb-11 10:07
professional dan!sh 6-Feb-11 10:07 
QuestionObtain the path and save the file. Pin
sososm6-Feb-11 2:45
sososm6-Feb-11 2:45 
AnswerRe: Obtain the path and save the file. Pin
OriginalGriff6-Feb-11 2:52
mveOriginalGriff6-Feb-11 2:52 
GeneralRe: Obtain the path and save the file. Pin
sososm6-Feb-11 5:39
sososm6-Feb-11 5:39 
AnswerRe: Obtain the path and save the file. Pin
Abhinav S6-Feb-11 6:10
Abhinav S6-Feb-11 6:10 
QuestionError: "Could not use"file name"; file already in use." [SOLVED] Pin
Marat Beiner5-Feb-11 22:26
Marat Beiner5-Feb-11 22:26 
AnswerRe: Error: "Could not use"file name"; file already in use." Pin
Elham M5-Feb-11 23:06
Elham M5-Feb-11 23:06 
AnswerRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff5-Feb-11 23:10
mveOriginalGriff5-Feb-11 23:10 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:18
Marat Beiner5-Feb-11 23:18 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff5-Feb-11 23:24
mveOriginalGriff5-Feb-11 23:24 
Thanks - that makes it easier.

C#
public void connectToDatabase()
    {
    DataBaseManager.conn = new OleDbConnection(this.dbConnPath);
    if (DataBaseManager.conn == null)
        {
        MessageBox.Show("Can't connect to database", "WorkManager", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    else
        {
        String state = DataBaseManager.conn.State.ToString();
        using (File.Open(Environment.CurrentDirectory + "\\" + userName + ".accdb", FileMode.Open))
            {
            if (state.Equals("Closed"))
                {
                DataBaseManager.conn.Open();
                }
            }
        }
    }
When you do the
DataBaseManager.conn.Open();
you have just opened the file immediately above...

using (File.Open(Environment.CurrentDirectory + "\\" + userName + ".accdb", FileMode.Open))
Since it is open, the connection cannot be made: the file is in use. Get rid of the File.Open code, and you should be fine...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:30
Marat Beiner5-Feb-11 23:30 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff5-Feb-11 23:32
mveOriginalGriff5-Feb-11 23:32 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:37
Marat Beiner5-Feb-11 23:37 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff5-Feb-11 23:42
mveOriginalGriff5-Feb-11 23:42 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
Marat Beiner5-Feb-11 23:57
Marat Beiner5-Feb-11 23:57 
GeneralRe: Error: "Could not use"file name"; file already in use." Pin
OriginalGriff6-Feb-11 0:24
mveOriginalGriff6-Feb-11 0:24 
AnswerRe: Error: "Could not use"file name"; file already in use." Pin
Eddy Vluggen6-Feb-11 1:09
professionalEddy Vluggen6-Feb-11 1:09 

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.