LoginSignup
0
0

cscの作法 その325

Posted at

概要

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

練習問題

sqliteで、selectで取得せよ。

サンプルコード

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 = "SELECT * FROM fruit";
					using (SQLiteDataReader Reader = Command.ExecuteReader())
					{
						while (Reader.Read())
						{
							int Id = Reader.GetInt32(0);
							string Name = Reader.GetString(1);
							int Number = Reader.GetInt32(2);
							int Price = Reader.GetInt32(3);
							Console.WriteLine(string.Format("id: {0} name: {1} number: {2} price: {3}", Id, Name, Number, Price));
						}
					}
				}
			}
			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