本文整理汇总了C#中System.Data.SQLite.SQLiteConnection.SetPassword方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.SetPassword方法的具体用法?C# SQLiteConnection.SetPassword怎么用?C# SQLiteConnection.SetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.SetPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveOrder
private int SaveOrder(string Production, int OrderQty, string Consignee, string Phone, string sheng, string shi, string xian, string Address, string Description)
{
int vcount = 0;
using (SQLiteConnection conn = new SQLiteConnection(config.DataSource))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.SetPassword(config.DBPwd);
conn.Open();
SQLiteHelper sh = new SQLiteHelper(cmd);
var dic = new Dictionary<string, object>();
dic["Production"] = Production;
dic["OrderQty"] = OrderQty;
dic["Consignee"] = Consignee;
dic["Phone"] = Phone;
dic["sheng"] = sheng;
dic["shi"] = shi;
dic["xian"] = xian;
dic["Address"] = Address;
dic["Description"] = Description;
vcount = sh.Insert("T_Order", dic);
conn.Close();
}
}
return vcount;
}
示例2: SetPwd
private static void SetPwd(string oldpwd,string newpwd)
{
using (SQLiteConnection conn = new SQLiteConnection(@"data source=F:\github\DFZ\source\DFZ.BenSeLing\App_Data\benseling.db"))
{
conn.SetPassword(oldpwd);
conn.Open();
conn.ChangePassword(newpwd);
conn.Close();
}
}
示例3: GetOrderList
public string GetOrderList(int pageRows,int page)
{
Dictionary<string, object> pageResult = new Dictionary<string, object>();
using (SQLiteConnection conn = new SQLiteConnection(config.DataSource))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.SetPassword(config.DBPwd);
conn.Open();
//conn.ChangePassword(config.DBPwd);
SQLiteHelper sh = new SQLiteHelper(cmd);
//总记录数
string totalSql = "Select count(1) From T_order";
long total = (long)sh.ExecuteScalar(totalSql);
int offset = (page - 1) * pageRows;
string sql = string.Format(@"SELECT ID,[Production]
,[Consignee]
,[Phone]
,[sheng]
,[shi]
,[xian]
,[Address]
,[Description],
case when status = 1 then
'√'
else
' '
end as status,
BuildTime
FROM [T_Order]
Order by Status asc ,buildTime desc
limit {0} offset {1} ",pageRows,offset);
DataTable dt = sh.Select(sql);
conn.Close();
pageResult.Add("total", total);
pageResult.Add("rows", dt);
}
}
return JSON.Encode(pageResult);
}
示例4: btnOK_Click
protected void btnOK_Click(object sender, EventArgs e)
{
string loginName = txtUser.Text;
string pwd = txtPwd.Text;
int count = 0;
using (SQLiteConnection conn = new SQLiteConnection(config.DataSource))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.SetPassword(config.DBPwd);
conn.Open();
SQLiteHelper sh = new SQLiteHelper(cmd);
Dictionary<string,object> para = new Dictionary<string,object>();
para.Add("@LoginName",loginName);
para.Add("@PassWord",pwd);
count = sh.ExecuteScalar<int>("select count(1) from T_User Where [email protected] And [email protected];",para);
conn.Close();
}
}
if (count > 0)
{
FormsAuthentication.SetAuthCookie(loginName, false);
if(string.IsNullOrEmpty(Request["ReturnUrl"]))
{
Response.Redirect("~/Admin/Order.aspx");
}
else
{
Response.Redirect(Request["ReturnUrl"]);
}
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(loginName, false);
}
else
{
Response.Write("<script>alert('用户名或密码错误!')</script>");
}
}
示例5: CreateConn
private static SQLiteConnection CreateConn(string dbName)
{
SQLiteConnection _conn = new SQLiteConnection();
try
{
string pstr = "pwd";
SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
connstr.DataSource = Environment.CurrentDirectory + dbName;
_conn.ConnectionString = connstr.ToString();
_conn.SetPassword(pstr);
_conn.Open();
return _conn;
}
catch (Exception exp)
{
Console.WriteLine("===CONN CREATE ERR====\r\n{0}", exp.ToString());
return null;
}
}
示例6: LoadDatabase
private void LoadDatabase(string databasePath)
{
try
{
sqlCon = new SQLiteConnection("Data Source=" + databasePath + ";Version=3;New=True;Compress=True;");
String dbFilename = System.IO.Path.GetFileName(databasePath);
String[] password = dbFilename.Split('@');
String[] dbPassword = password[1].Split('_');
String p = password[0] + dbPassword[0];
sqlCon.SetPassword(password[0] + dbPassword[0]);
sqlCon.Open(); //open the connection
sqlCmd = sqlCon.CreateCommand();
//Update this command to nates new table structure...
string commandText = "select filename, filePath, count, priority, pattern_D9_Count, pattern_D324_Count from Scanned";
sqlDataAdapter = new SQLiteDataAdapter(commandText, sqlCon);
dSetScanned.Reset();
sqlDataAdapter.Fill(dSetScanned);
dTableScanned = dSetScanned.Tables[0];
dataGridView_Social.DataSource = dTableScanned;
commandText = "select filename, filePath, count, priority, visa, mastercard, americanExpress, discover, dinerClub, JCB from CreditCard";
sqlDataAdapter = new SQLiteDataAdapter(commandText, sqlCon);
dSetCreditCard.Reset();
sqlDataAdapter.Fill(dSetCreditCard);
dTableCreditCard = dSetCreditCard.Tables[0];
dataGridView_Credit.DataSource = dTableCreditCard;
commandText = "select filePath from UnScannable";
sqlDataAdapter = new SQLiteDataAdapter(commandText, sqlCon);
dSetNotScanned.Reset();
sqlDataAdapter.Fill(dSetNotScanned);
dTableNotScanned = dSetNotScanned.Tables[0];
dataGridView_NotScanned.DataSource = dTableNotScanned;
}
catch (SQLiteException e)
{
MessageBox.Show(e.Message);
}
}
示例7: DatabaseCreateTables
/// <summary>
/// Create DB if not exists
/// Create Default tables
/// </summary>
public static void DatabaseCreateTables()
{
// We use these three SQLite objects:
SQLiteConnection sqliteConn;
SQLiteCommand sqliteCmd;
// create a new database connection:
sqliteConn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;Password=" + GameConstans.DB_PASSWORD + ";");
sqliteConn.SetPassword(GameConstans.DB_PASSWORD);
// open the connection:
sqliteConn.Open();
// create a new SQL command:
sqliteCmd = sqliteConn.CreateCommand();
sqliteCmd.CommandText = "SELECT * FROM sqlite_master";
var name = sqliteCmd.ExecuteScalar();
// check account table exist or not
// if exist do nothing
if (name == null)
{
for (int row = 4; row < 8; row++)
{
for (int col = 4; col < 8; col++)
{
// Tables not exist, create tables
sqliteCmd.CommandText = "CREATE TABLE '" + row + col + "' (rowID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE DEFAULT 1, playerName VARCHAR(20), moves INT, time INT, score INT)";
sqliteCmd.ExecuteNonQuery();
}
}
}
// We are ready, now lets cleanup and close our connection:
sqliteConn.Close();
}
示例8: DeleteOrder
public int DeleteOrder(string orderId)
{
int count = 0;
using (SQLiteConnection conn = new SQLiteConnection(config.DataSource))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.SetPassword(config.DBPwd);
conn.Open();
SQLiteHelper sh = new SQLiteHelper(cmd);
string sql = @"Delete From [T_Order] Where ID = @ID";
Dictionary<string, object> para = new Dictionary<string, object>();
para.Add("@ID", orderId);
count = sh.Execute(sql,para);
conn.Close();
}
}
return count;
}
示例9: GetNewConnection
public DbConnection GetNewConnection()
{
switch (DatabaseProvider)
{
case DatabaseProvider.SQLServer:
return new SqlConnection(GetConnectionString());
case DatabaseProvider.Oracle:
return new OracleConnection(GetConnectionString());
case DatabaseProvider.SqlCe4:
return new SqlCeConnection(GetConnectionString());
case DatabaseProvider.SQLite:
var conn = new SQLiteConnection(GetConnectionString());
if (!string.IsNullOrEmpty(SqlPassword))
{
conn.SetPassword(SqlPassword);
}
return conn;
default:
throw new NotSupportedException("Database type is not supported");
}
}
示例10: ExecuteReader
/// <summary>
/// 执行数据库查询,返回SqlDataReader对象
/// </summary>
/// <param name="connectionString">连接字符串</param>
/// <param name="commandText">执行语句或存储过程名</param>
/// <param name="commandType">执行类型</param>
/// <returns>SqlDataReader对象</returns>
public static DbDataReader ExecuteReader(string connectionString, string commandText, CommandType commandType)
{
DbDataReader reader = null;
if (connectionString == null || connectionString.Length == 0)
throw new ArgumentNullException("connectionString");
if (commandText == null || commandText.Length == 0)
throw new ArgumentNullException("commandText");
SQLiteConnection con = new SQLiteConnection(connectionString);
con.SetPassword("123456");
SQLiteCommand cmd = new SQLiteCommand();
SQLiteTransaction trans = null;
PrepareCommand(cmd, con, ref trans, false, commandType, commandText);
try
{
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception ex)
{
throw ex;
}
return reader;
}
示例11: CreateBase
//public List<String> tVacation { get; set; }
//public List<String> tSick { get; set; }
//public List<String> tBTrip { get; set; }
public void CreateBase()
{
if (!File.Exists(DataBaseName))
{
SQLiteConnection.CreateFile(DataBaseName);
SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=DBTels.sqlite;Version=3;");
m_dbConnection.SetPassword(pass);
}
}
示例12: GetDBConnection
/// <summary>
/// 获取数据库链接
/// </summary>
/// <returns></returns>
public static SQLiteConnection GetDBConnection()
{
SQLiteConnection conn = new SQLiteConnection();
SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
connstr.JournalMode = SQLiteJournalModeEnum.Wal;
connstr.DataSource = dataSource;
if (new XMLReader().ReadXML("注册").Equals("true"))
{
conn.SetPassword(dbPassword);
}
conn.ConnectionString = connstr.ToString();
return conn;
}
示例13: ExecuteNonQuery
/// <summary>
/// Allows the programmer to interact with the database for purposes other than a query.
/// </summary>
/// <param name="sql">The SQL to be run.</param>
/// <returns>Number of records affected.</returns>
public override int ExecuteNonQuery(string sql)
{
using (var cnn = new SQLiteConnection(DbConnection))
using (var mycommand = new SQLiteCommand(cnn))
{
if (string.IsNullOrWhiteSpace(_pass))
cnn.SetPassword(_pass);
cnn.Open();
mycommand.CommandText = sql;
int recordsAffected = mycommand.ExecuteNonQuery();
cnn.Close();
return recordsAffected;
}
}
示例14: DBhandler
private void DBhandler()
{
_path = Path.Combine(RepairShoprUtils.folderPath, "RepairShopr.db3");
FileInfo fileInfo = new FileInfo(_path);
if (!fileInfo.Exists)
{
SQLiteConnection.CreateFile(_path);
try
{
using (SQLiteConnection con = new SQLiteConnection("data source=" + _path + ";PRAGMA journal_mode=WAL;"))
{
con.SetPassword("shyam");
con.Open();
SQLiteCommand cmdTableAccount = new SQLiteCommand("CREATE TABLE Account (Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT ,AccountId nvarchar(50),CustomerId nvarchar(50))", con);
cmdTableAccount.ExecuteNonQuery();
SQLiteCommand cmdTableTicket = new SQLiteCommand("CREATE TABLE Ticket (Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,TicketId nvarchar(50),RTicketId nvarchar(30))", con);
cmdTableTicket.ExecuteNonQuery();
SQLiteCommand cmdTableInvoice = new SQLiteCommand("CREATE TABLE Invoice (Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,InvoiceId nvarchar(50),RinvoiceId nvarchar(50))", con);
cmdTableInvoice.ExecuteNonQuery();
con.Close();
}
}
catch (Exception ex)
{
RepairShoprUtils.LogWriteLineinHTML("Failed to Create Datebase Setting", MessageSource.Initialization, ex.StackTrace, messageType.Error);
}
}
}
示例15: BulkInsert
/// <summary>
/// Fast insert of many records
/// </summary>
/// <param name="tableName">SQL Database table name</param>
/// <param name="data">Data to insert</param>
/// <returns>Number of records affected.</returns>
public override int BulkInsert(string tableName, DataTable data)
{
int recordsAffected = 0;
using (var cnn = new SQLiteConnection(DbConnection))
{
if (string.IsNullOrWhiteSpace(_pass))
cnn.SetPassword(_pass);
cnn.Open();
using (SQLiteTransaction trans = cnn.BeginTransaction())
using (SQLiteCommand cmd = cnn.CreateCommand())
{
string cols = data.Columns.Cast<DataColumn>().Aggregate(string.Empty, (current, col) => current + (string.Format("{0},", col.ColumnName ))).TrimEnd(',');
string colsp = data.Columns.Cast<DataColumn>().Aggregate(string.Empty, (current, col) => current + (string.Format("@{0},", col.ColumnName))).TrimEnd(',');
cmd.CommandText = string.Format("INSERT INTO {0}({1}) VALUES({2})", tableName, cols, colsp);
foreach (DataColumn col in data.Columns)
{
cmd.Parameters.Add(new SQLiteParameter(col.ColumnName));
}
for (int rowIndex = 0; rowIndex < data.Rows.Count; rowIndex++)
{
for (int colIndex = 0; colIndex < data.Columns.Count; colIndex++)
{
string colName = data.Columns[colIndex].ColumnName;
cmd.Parameters[colName].Value = data.Rows[rowIndex][colName];
}
recordsAffected += cmd.ExecuteNonQuery();
}
trans.Commit();
}
cnn.Close();
}
return recordsAffected;
}