1-我在app.config中添加了一个SQLite连接字符串,当我调用它时,表单设计器中出现了错误(对象引用未设置为对象的实例) Designer error image
2-我试图通过索引号获取连接字符串,设计器中出现了另一个错误(无法加载DLL'SQLite.Interop.dll':找不到指定的模块。(HRESULT的异常) :0x8007007E)) Designer error image
App.config :
<connectionStrings>
<add
name="Cons"
connectionString="Data Source=|DataDirectory|PT.db; Version=3;"
providerName="System.Data.Sqlite"
/>
</connectionStrings>
课堂通话:
public class SQL
{
private static SQLiteConnection con = new SQLiteConnection(ConfigurationManager.ConnectionStrings["Cons"].ConnectionString);
public static void Open()
{
con.Open();
}
}
[更新]
我发现在ControlTime class
中从SQL UserControl
调用任何方法作为此代码时会出现此问题
public partial class ControlTime : UserControl
{
public ControlTime()
{
InitializeComponent();
SQL.Open(); // if i remove this line the error disappears
}
}
在窗体设计器中没有任何错误的情况下,我该怎么做才能调用SQL Class
?
答案 0 :(得分:0)
尝试使用此连接字符串:
select
iif(t.name like "*,*", trim(mid(t.name, instr(t.name, ",")+1, len(t.name) - instr(t.name, ",") - iif(t.name like "* ?", 2, 0))), iif(t.name like "* ?", left(t.name, len(t.name)-2), t.name)) as FName,
iif(t.name like "*,*", left(t.name, instr(t.name, ",")-1), Null) as LName,
iif(trim(t.name) like "* ?", right(trim(t.name), 1), Null) as MName
from
YourTable t