2012-06-28 7 views
3
내가 오류 얻을

"데이터 소스는 비워 둘 수 없습니다" "데이터 소스가 비어있을 수 없습니다를 사용합니다. 메모리 : 메모리 데이터베이스를 엽니 다"SQLite는

// Get Current Users App Data 
      string documentsFolder = Environment.GetFolderPath 
      (Environment.SpecialFolder.ApplicationData); 
      string[] tempstr = documentsFolder.Split('\\'); 
      string tempstr1 = ""; 
      documentsFolder += "\\Google\\Chrome\\User Data\\Default\\History"; 
      if (tempstr[tempstr.Length - 1] != "Local") 
      { 
       for (int i = 0; i < tempstr.Length - 1; i++) 
       { 
        tempstr1 += tempstr[i] + "\\"; 
       } 
       documentsFolder = tempstr1 + "Local\\Google\\Chrome\\User Data\\Default\\History"; 
      } 

      // Check if directory exists 
      if (Directory.Exists(documentsFolder)) 
      { 
      // return ExtractUserHistory(documentsFolder); 

      } 

      string connectionString; 
      connectionString = string.Format(@"DataSource={0}", documentsFolder); 
다음

내 연결 문자열입니다 어떤 도움

SQLiteConnection conn = new SQLiteConnection(connectionString); 
    conn.Open(); 

감사 :

그리고 여기 내 연결입니다.

+0

http://stackoverflow.com/questions/4039720/c-sharp-sqlite-what-is-data-source-cannot-be-empty-use-memory-to-open-an – paragy

+0

당신은 이것을 단순화 할 수 있습니다. 'Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData)'를 사용한다면, * ROAMING * 대신에 * LOCAL *이 항상 필요하다. 또한 [Path.Combine] (http://msdn.microsoft.com/en-us/library/dd781134) 또는 적어도 [StringBuilder.Append] (http://msdn.microsoft.com/en-us/) 사용을 고려하십시오. 라이브러리/ds86a594)를 사용하는 것이 좋습니다. – Filburt

답변

6

연결 문자열이 잘못된 경우 오류가 발생합니다. 에서

당신이

는 희망이 도움이 데이터 소스 대신에 데이터 소스를 삽입해야 @"Data Source={0}" .

+0

고마워요! 그리고 Google에이 오류 메시지의 두 번째 결과였습니다 ... 나는이 세부 사항을 꽤 오랫동안 사냥하고있었습니다. – jon3laze