本文整理汇总了C#中System.Data.SQLite.SQLiteConnectionStringBuilder.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnectionStringBuilder.ToString方法的具体用法?C# SQLiteConnectionStringBuilder.ToString怎么用?C# SQLiteConnectionStringBuilder.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteConnectionStringBuilder
的用法示例。
在下文中一共展示了SQLiteConnectionStringBuilder.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connection
//Set up the connection with the password
public static SQLiteConnection Connection(string dbname, string pwd)
{
string datasource = dbname;
SQLiteConnection.CreateFile(datasource);
//连接数据库
SQLiteConnection connection = new SQLiteConnection();
SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
connstr.DataSource = datasource;
connstr.Password = pwd;//设置密码,SQLite ADO.NET实现了数据库密码保护
//将连接的信息传递给connection
connection.ConnectionString = connstr.ToString();
if (connection == null)
{
connection = new SQLiteConnection();
connection.ConnectionString = connstr.ToString();
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
return connection;
}
示例2: DBManager
public DBManager(String dataSource)
{
// build connection string
SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
builder.DataSource = dataSource;
connectionString = builder.ToString();
}
示例3: TestQuery
public void TestQuery()
{
var builder = new SQLiteConnectionStringBuilder();
builder.DataSource = "test.db";
using (DbConnection connection = new SQLiteConnection(builder.ToString()))
{
connection.Open();
using (var cmd1 = connection.CreateCommand())
{
cmd1.CommandText = @"SELECT name FROM sqlite_master WHERE type='table' AND name='table_test';";
var reader = cmd1.ExecuteReader();
if (reader.Read())
{
var tableName = reader.GetString(0);
System.Diagnostics.Trace.WriteLine(String.Format("table name={0}", tableName));
}
else
{
using (var cmd2 = connection.CreateCommand())
{
cmd2.CommandText = @"Create Table 'table_test' (num Integer, str)";
cmd2.ExecuteNonQuery();
}
}
}
}
}
示例4: CardRefundPayService
public CardRefundPayService()
{
string localDriver = "C";
if (Directory.Exists("D:\\"))
{
localDriver = "D";
}
string dbPath = localDriver + ":\\DataBase\\top4pos.db3";
if (!File.Exists(dbPath))
{
//创建数据库
SQLiteConnection.CreateFile(dbPath);
}
SQLiteConnectionStringBuilder connectionString = new SQLiteConnectionStringBuilder
{
DataSource = dbPath,
Password = "123",
Pooling = true,
FailIfMissing = false
};
m_SQLiteHelper = new SQLiteHelper(connectionString.ToString());
//判断表是否存在
string strSql = "SELECT COUNT(*) FROM sqlite_master where type='table' and name='CardRefundPay'";
if (!m_SQLiteHelper.Exists(strSql))
{
string createTableSql = @"create table CardRefundPay(StoreValueID INTEGER primary key autoincrement,
CardNo varchar(50), ShopID varchar(36),
TradePayNo varchar(30),
PayAmount decimal(12, 4), EmployeeNo varchar(20),
DeviceNo varchar(16), IsFixed Integer,
CreateTime datetime, LastTime datetime);";
m_SQLiteHelper.ExecuteSql(createTableSql);
}
}
示例5: SQLiteDescriptor
/// <summary>
/// Constructor for talking to a SQLite database.
/// </summary>
/// <param name="databasePath">Path to the db file.</param>
public SQLiteDescriptor(string databasePath)
{
if (!StringHelper.IsNonBlank(databasePath))
{
throw new ArgumentNullException("databasePath", "Database file path cannot be null/blank.");
}
SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
builder.DataSource = _databasePath = databasePath;
// we want to disable pooling so we don't wind up locking
// the file indefinitely.
builder.Pooling = false;
_usePooling = false;
// There is no password, so the strings are the same.
_cleanConnStr = builder.ToString();
_connectionStr = builder.ToString();
}
示例6: getSqlLiteDB
/// <summary>
/// 获得连接数据库
/// </summary>
/// <param name="datasource"></param>
/// <returns></returns>
public SQLiteConnection getSqlLiteDB(String datasource)
{
SQLiteConnection conn = new SQLiteConnection();
SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
connstr.DataSource = "databases/" + datasource + ".db";
conn.ConnectionString = connstr.ToString();
return conn;
}
示例7: Storage
public Storage()
{
string datasource = "map.db";
if (!System.IO.File.Exists(datasource))
SQLiteConnection.CreateFile(datasource);
conn = new SQLiteConnection();
conStr = new SQLiteConnectionStringBuilder();
conStr.DataSource = datasource;
conn.ConnectionString = conStr.ToString();
// open connection;
conn.Open();
SQLiteCommand cmd = new SQLiteCommand();
string sql = string.Empty;
cmd.Connection = conn;
sql = "drop table if exists label;";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "drop table if exists path;";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "drop table if exists quadtree;";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "create table label (id INTEGER, data BLOB);";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "create table path (id INTEGER, data BLOB);";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "create table quadtree (quadkey TEXT, data BLOB);";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "create index label_id ON label(id);";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "create index path_id ON path(id);";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
sql = "create index quadtree_quadkey ON quadtree (quadkey);";
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
示例8: DbTestSqlLiteAdo
public DbTestSqlLiteAdo()
{
SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder {DataSource = PathToDb};
pConnectionString = builder.ToString();
Random r = new Random();
pRandomString = r.NextDouble().ToString();
bool ok = SetDllDirectory(PathToDll);
Debug.Assert(ok);
}
示例9: BookDataBase
private BookDataBase()
{
conn = new SQLiteConnection();
connstr = new SQLiteConnectionStringBuilder();
cmd = new SQLiteCommand();
connstr.DataSource = dbName;
conn.ConnectionString = connstr.ToString();
conn.Open();
}
示例10: LemmaDatabase
public LemmaDatabase(string fileName)
{
SQLiteConnectionStringBuilder connBuilder = new SQLiteConnectionStringBuilder();
connBuilder.DataSource = fileName;
connBuilder.Version = 3;
conn = new SQLiteConnection(connBuilder.ToString());
conn.Open();
InitializeDatabase();
}
示例11: SQLite
static SQLite()
{
//var constring = [email protected]"Data Source={_dbPath};Version=3;";
var constring = new SQLiteConnectionStringBuilder
{
DataSource = _dbPath,
Version = 3,
};
Connection = new SQLiteConnection(constring.ToString()) {ParseViaFramework = true};
//
}
示例12: DBHandler
private DBHandler()
{
this.connection = new SQLiteConnection();
string datasource = ConfigurationManager.AppSettings["DataSource"].ToString();
SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
connstr.DataSource = datasource;
this.connection.ConnectionString = connstr.ToString();
this.connection.Open();
this.dataContext = new StudentDataContext(this.connection);
}
示例13: SQLiteUrlTokenStore
/// <summary>
/// Initializes a new instance of the SQLiteUrlTokenStore class.
/// </summary>
/// <param name="connectionString">The connection string to use when connecting to the database.</param>
public SQLiteUrlTokenStore(string connectionString)
{
this.ConnectionString = connectionString;
this.EnsureConnectionString();
SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder(this.ConnectionString);
builder.DataSource = ResolveDatabasePath(builder.DataSource);
this.ConnectionString = builder.ToString();
EnsureDatabase(builder.DataSource);
}
示例14: Initialize
//Initialize values
private void Initialize(string db_name, string db_password)
{
connectionString = new SQLiteConnectionStringBuilder();
connectionString.DataSource = db_name;
connectionString.Version = 3;
if(!String.IsNullOrEmpty(db_password))
connectionString.Password = db_password;
connection = new SQLiteConnection(connectionString.ToString());
}
示例15: ImageCache
public ImageCache(string filename)
{
var builder = new SQLiteConnectionStringBuilder
{
BinaryGUID = true,
DataSource = filename,
Version = 3
};
string connectionString = builder.ToString();
m_sqlCon = new SQLiteConnection(connectionString);
m_sqlCon.Open();
}