1- I have added a SQLite connection string in app.config, and when i call it, an error appears in the form designer (Object reference not set to an instance of an object) Designer error image
2- I tried to get the connection string by index number, a different error appears in designer (Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) ) Designer error image
App.config:
<connectionStrings>
<add
name="Cons"
connectionString="Data Source=|DataDirectory|PT.db; Version=3;"
providerName="System.Data.Sqlite"
/>
</connectionStrings>
in class call:
public class SQL
{
private static SQLiteConnection con = new SQLiteConnection(ConfigurationManager.ConnectionStrings["Cons"].ConnectionString);
public static void Open()
{
con.Open();
}
}
[Update]
I found this problem presents when i call any method from SQL class
in ControlTime UserControl
as this code
public partial class ControlTime : UserControl
{
public ControlTime()
{
InitializeComponent();
SQL.Open(); // if i remove this line the error disappears
}
}
What can i do to call SQL Class
with out any error in the Form designer?
Try this Connectionstring:
<connectionStrings>
<add name="Cons"
connectionString="data source=.\PT.sqlite"
providerName="System.Data.SQLite"/>
</connectionStrings>
User contributions licensed under CC BY-SA 3.0