本文介绍了如何在ASP.NET上使用BLToolkit连接SqliteDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我连接到sqlitedb时出错.
Hi i got an error while connection to my sqlitedb.
我使用Firefox Sqlite Addon创建我的sqlitedb.
I create my sqlitedb using Firefox Sqlite Addon.
MyConn:(webconfig)
MyConn : (webconfig)
<connectionStrings>
<add name="TARKMANCAS_CONNECTION" connectionString="Data Source=C:/TARKMANCAS_DB.sqlite;"/>
</connectionStrings>
MyClass:
public TarkBaseDb()
: base("TARKMANCAS_CONNECTION")
{
}
// start
//
public Table<TarkBaseSchema.KadroGrubuCls> KadroGrubu { get { return GetTable<TarkBaseSchema.KadroGrubuCls>(); } }
TarkBaseSchema:
TarkBaseSchema:
[TableName("EGITIM_KADROSU_GRUBU_TAB")]
public class KadroGrubuCls
{
private TarkBaseDb db = new TarkBaseDb();
#region Contructors
public KadroGrubuCls()
{
using (db)
{
var qry = from x in db.KadroGrubu
select x;
foreach (var rec_ in qry)
{
KadroGrubuId = rec_.KadroGrubuId;
KadroGrubu = rec_.KadroGrubu;
}
}
}
#endregion
#region Data Items
[MapField("KADRO_GRUBU_ID")]
[PrimaryKey, NotNull]
public int KadroGrubuId { get; set; }
[MapField("KADRO_GRUBU")]
public string KadroGrubu { get; set; }
#endregion
#region Relations
#endregion
#region Public Methods
public KadroGrubuCls Get()
{
return (new KadroGrubuCls());
}
#endregion
}
并尝试拨打电话:
TarkBaseSchema.KadroGrubuCls _tarkKadro = _tarkKadro.Get();
我遇到了错误:
A network-related or instance-specific error occurred while establishing a connection to
SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
推荐答案
错误消息表明它正在尝试连接到SQL Server,而不是SQLite.
The error message shows that it's trying to connect to SQL Server, not SQLite.
更改连接字符串以选择正确的驱动程序.
(并且在数据"和源"之间有两个空格.)
Change the connection string to select the correct driver.
(And you have two spaces between "Data" and "Source".)
这篇关于如何在ASP.NET上使用BLToolkit连接SqliteDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!