0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

cscの作法 その69

Posted at

概要

cscの作法、調べてみた。
mdbにsql投げて合計求めてみた。

コンパイル手順

>csc sql1.cs /platform:x86

サンプルコード

using System;
using System.Data.OleDb;
using System.Data;
using System.IO;
using System.Text;
using System.Collections.Generic;

public static class Program {
	public static void Main(params string[] args) {
		OleDbConnection con = new OleDbConnection();
		con.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=mydb.mdb;";
		con.Open();
		string sSQL = "SELECT SUM(金額) FROM sisyutu WHERE 項目 = '食料'";
		OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(sSQL, con);
		object sum = cmd.ExecuteScalar();
		Console.WriteLine(sum + "円です。");
		int i = Convert.ToInt32(sum);
		Console.WriteLine(i);
	}
}

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?