LoginSignup
0
0

cscの作法 その324

Posted at

概要

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

練習問題

sqliteで、insert intoを発行せよ。

サンプルコード

using System;
using System.Text;
using System.IO;
using System.Data.SQLite;

namespace App
{
	public class Program {
		public static void Main(string[] args) {
			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 = "INSERT INTO fruit(id, name, number, price) VALUES (:id, :name, :number, :price)";
					Command.Parameters.Add(new SQLiteParameter("id", 1));
					Command.Parameters.Add(new SQLiteParameter("name", "mango"));
					Command.Parameters.Add(new SQLiteParameter("number", 2));
					Command.Parameters.Add(new SQLiteParameter("price", 500));
					Command.ExecuteNonQuery();
				}
			}
			Console.WriteLine("ok0");
		}
	}
}



以上。

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