// insert.cs using System; using System.Data.SqlClient; public class Insert { public static void Main(string[] args) { if (args.Length != 2) return; string connStr = "Server=(local)\\NetSDK;" + "Trusted_Connection=yes;" + "database=pubs"; string sqlStr = "INSERT INTO publishers(pub_id, pub_name) " + " VALUES ('{0}', '{1}')"; sqlStr = String.Format(sqlStr, args[0], args[1]); SqlConnection conn = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(sqlStr, conn); conn.Open(); int num = cmd.ExecuteNonQuery(); Console.WriteLine(num); conn.Close(); } } // コンパイル方法:csc insert.cs