"Wert kann nicht null sein. (Parameter 'Path1')" auf ConnectionString
Posted: 08 Feb 2025, 04:35
Beim Debuggen kann ich eine erfolgreiche Verbindung zu einer SQLite -Datenbank herstellen. Nach dem Erstellen der .NET -Anwendung SQLITE hat jedoch Probleme mit system.io.path.combine :
in Zeile 23).
Code: Select all
at System.IO.Path.Combine(String path1, String path2)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
at LDF_DetectionTool.DatabaseConnector.GetApplicationsList() in SomePath\DatabaseConnector.cs:line 23
< /code>
Der Code: < /p>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
using System.Data;
namespace LDF_DetectionTool
{
internal class DatabaseConnector
{
public List GetApplicationsList()
{
string databaseFileName = "Databases\\LDF_DETECTION_TOOL_DATA.db";
string databaseFilePath = AppDomain.CurrentDomain.BaseDirectory + databaseFileName;
string connectionString = "Data Source=" + databaseFilePath;
List applicationList = new List();
try
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString, true))
{
connection.Open();
string query = "SELECT * FROM APPLICATIONS";
using (SQLiteCommand command = new SQLiteCommand(query, connection))
{
using (SQLiteDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
applicationList.Add(reader.GetString(0));
}
}
}
connection.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(connectionString);
MessageBox.Show(ex.Message);
MessageBox.Show(ex.StackTrace);
}
return applicationList;
}
< /code>
Die Ausnahmeregelung: < /p>
Der Wert kann nicht null sein. (Parameter 'Path1') < /p>
< /blockquote>
Keine der Variablen ist null (ich kann sie auch nach dem Erstellen in Messageboxen anzeigen). Nach dem Aufbau stimmt etwas nicht, das beim Debuggen funktioniert. Die Datenbank befindet sich am richtigen Ort. Starten Sie Visual Studio neu und erstellen Sie erneut und setzennew SQLiteConnection(connectionString, false)