LoginSignup
0
0

cscの作法 その335

Posted at

概要

cscの作法、調べてみた。
練習問題、やってみた。

練習問題

sqliteでsqlを直接、実行するツールを作れ。

写真

image.png

サンプルコード


using System;
using System.Text;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using System.Data.Common;
using System.Transactions;
using System.Data.SQLite;

class form1: Form {
	private Button sButton = new Button();
	private TextBox bo1 = new TextBox();
	form1() {
		Text = "SQLite";
		ClientSize = new Size(400, 300);
		bo1.Location = new Point(20, 20);
		bo1.Text = "DELETE FROM fruit WHERE id = 3";
		bo1.Width = 360;
    	bo1.Height = 200;
		bo1.Multiline = true;
		sButton.Location = new Point(300, 240);
		sButton.Text = "submit";
		sButton.Click += new EventHandler(SButton_Click);
		Controls.AddRange(new Control[] {
			bo1,
			sButton
		});
	}
	private void SButton_Click(object sender, EventArgs e) {
			SQLiteConnectionStringBuilder ConnectionStr = new SQLiteConnectionStringBuilder();
			ConnectionStr.DataSource = "db0.sqlite";
			using (SQLiteConnection Connection = new SQLiteConnection(ConnectionStr.ToString()))
			{
				Connection.Open();
				using(SQLiteCommand Command = new SQLiteCommand(Connection))
				{
					Command.CommandText = bo1.Text;
					Command.ExecuteNonQuery();
				}
			}
			Console.WriteLine("ok0");
	}
	[STAThread]
	public static void Main() {
		Application.Run(new form1());
	}
}





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0