标签:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using System.Configuration; using winformlogin; namespace datareader { class Program { static void Main(string[] args) { string bankStr = DBHelper.connStr; using (SqlConnection con = new SqlConnection(bankStr)) { //string sql = "insert into Grade values(@GradeName)"; //string sql = "update Grade set GradeName=@GradeName where GradeName=‘s8‘"; string sql = "delete from Grade where GradeName=@GradeName"; SqlCommand cmd = new SqlCommand(sql,con); cmd.Parameters.AddWithValue("@GradeName",Console.ReadLine()); con.Open(); int n = cmd.ExecuteNonQuery(); if (n != 1) { Console.WriteLine("error"); } } Console.ReadKey(); } } }
至于select:
用datareader。
标签:
原文地址:http://www.cnblogs.com/Penfield/p/4347213.html