/// <要約> ///が構文を実行する[新規法が削除] /// </要約> /// <PARAM NAME = "SQLTEXT"> SQL構文</ PARAM> /// <戻りA> </返します> パブリック 非同期タスク< INT > ExecuteNoneQuery(文字列SQLTEXT、SQLiteParameter [] SPR) { SQLiteConnection CNは = 新しい新しいSQLiteConnection(_datasource); // データベースに接続 cn.ConnectionString = GetSQLiteConnectionString(_datasource); cn.Open(); SQLiteCommand CMD = 新しい新SQLiteCommand(); cmd.Connection = CN; cmd.CommandText = SQLTEXT。 // 多个参数 のforeach(SQLiteParameter属におけるSPR) { cmd.Parameters.Add(SP)。 } int型の数は= 待つcmd.ExecuteNonQueryAsyncを(); cn.Close(); 戻り値の数。 }
/// <要約> /// 接続文字列を取得 /// </要約> /// <PARAM NAME = "データソース"> 接続文字列</ param>の /// <戻り値> </戻り値> 公共の 文字列 GetSQLiteConnectionString(文字列データソース) { // データベースに接続 SQLiteConnectionStringBuilder connstr = 新新SQLiteConnectionStringBuilder(); connstr.DataSource = データソース; connstr.Password = " 123456 " ; //は、パスワード、達成するために保護されたSQLite ADO.NETデータベースのパスワード設定 リターンをconnstr.ToString(); }
WebConfig
< のconnectionStrings > < 追加名= "DefaultConnectionを" たconnectionString = "データベース// fang_cheng.db" /> </ のconnectionStrings >
コール
SQLiteParameter [] SPR = { 新しい SQLiteParameter(" @code " 、製品コード)}。 affectRow = 待つ ExecuteNoneQuery(SQLTEXT、SPR)を、