お世話になります。
パスワードを管理するシステムを作っております。
今、画面から登録ボタンを押した時にDBに登録するロジックを実装しているのですが
行き詰まっています。
どなたかご教示のほどよろしくお願い致します。
型 'System.Data.SQLite.SQLiteException' のハンドルされていない例外が System.Data.SQLite.dll で発生しました
追加情報:SQL logic error or missing database
no such table: PASS_KANRI
C#
1using System; 2using System.Collections.Generic; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Linq; 7using System.Text; 8using System.Threading.Tasks; 9using System.Windows.Forms; 10using System.Data.SQLite; 11 12namespace WindowsFormsApplication4 13{ 14 public partial class Touroku : Form 15 { 16 17 18 public Touroku() 19 { 20 InitializeComponent(); 21 textToday.Text = DateTime.Now.ToString("yy/MM/dd"); 22 } 23 24 private void label4_Click(object sender, EventArgs e) 25 { 26 27 } 28 29 private void textToday_TextChanged(object sender, EventArgs e) 30 { 31 32 } 33 34 private void buttonLogin_Click(object sender, EventArgs e) 35 { 36 string random = Guid.NewGuid().ToString("N").Substring(0, 8); 37 textPasssei.Text = random; 38 } 39 40 private void button1_Click(object sender, EventArgs e) 41 { 42 string dbConnectionString = "Data Source = E:\\myfriend.sqlite3.db"; 43 using (SQLiteConnection cn = new SQLiteConnection(dbConnectionString)) { 44 cn.Open(); 45 using (SQLiteTransaction trans = cn.BeginTransaction()) { 46 SQLiteCommand cmd = cn.CreateCommand(); 47 //DBにインサート 48 cmd.CommandText = "INSERT INTO PASS_KANRI (No,LoginId,Password,Todate,BIKO) VALUES(@No,@LoginId,@Password,@Todate,@BIKO)"; 49 50 //パラメータのセット 51 cmd.Parameters.Add("No", System.Data.DbType.String); 52 cmd.Parameters.Add("LoginId", System.Data.DbType.String); 53 cmd.Parameters.Add("Password", System.Data.DbType.String); 54 cmd.Parameters.Add("Todate", System.Data.DbType.String); 55 cmd.Parameters.Add("BIKO", System.Data.DbType.String); 56 57 cmd.Parameters["No"].Value = textBox1.Text; 58 cmd.Parameters["LoginId"].Value = textSiteNm.Text; 59 cmd.Parameters["Password"].Value = textPW.Text; 60 cmd.Parameters["Todate"].Value = textToday.Text; 61 cmd.Parameters["BIKO"].Value = TextBIKO.Text; 62 63 cmd.ExecuteNonQuery(); 64 trans.Commit(); 65 66 } 67 } 68 } 69 70 private void label8_Click(object sender, EventArgs e) 71 { 72 73 } 74 75 private void textBox1_TextChanged(object sender, EventArgs e) 76 { 77 78 } 79 } 80} 81 82
回答2件
あなたの回答
tips
プレビュー