增
代码展示
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace sql增
{
class Program
{
static void Main(string[] args)
{
string connStr = "Data Source=.;Initial Catalog=ceshi;Integrated Security=True";
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
String sql = "update atm set age=1500 where id=20";
Console.WriteLine(sql);
SqlCommand cmd = new SqlCommand(sql, conn);
Console.WriteLine(cmd);
int n = cmd.ExecuteNonQuery();
Console.WriteLine("受影响的行数是:" + n);
conn.Close();
Console.ReadKey();
}
}
}
改(删)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace sql改
{
class Program
{
static void Main(string[] args)
{
string connStr = "Data Source=.;Initial Catalog=ceshi;Integrated Security=True";
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
String sql = "insert into atm values('赛迦奥特曼',900,'奥特曼')";
Console.WriteLine(sql);
SqlCommand cmd = new SqlCommand(sql, conn);
Console.WriteLine(cmd);
int n = cmd.ExecuteNonQuery();
Console.WriteLine("受影响的行数是:" + n);
conn.Close();
Console.ReadKey();
}
}
}