http://blog.csdn.net/pan_junbiao/article/details/7015633 (LINQ To SQL 语法及实例大全) 代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System; using System.Collections.Generic; using System.Linq; u…
1.增 INSERT INTO table_name VALUES (value1, value2,....) INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....) 2.删 DELETE FROM table_name WHERE 列名称 = 值 3.改 UPDATE table_name SET 列名称 = 新值 WHERE 列名称 = 某值 UPDATE Person SET FirstName = 'Fred' WHERE Las…
约束 public abstract class BaseModel { public int Id { get; set; } } 连接字符串 public static readonly string Customers = ConfigurationManager.ConnectionStrings["Customers"].ToString(); 通用数据库字符串 public class SqlBuilder<T> where T : BaseModel { pu…
Framework版本:.Net Framework 4 ConnectionUtil源码参见:https://www.cnblogs.com/threadj/p/10536273.html using System; using System.Collections.Generic; using System.Linq; using System.Web; using MongoDB.Driver; using MongoDB.Bson; using MongoDB.Driver.Builde…
using System; using System.Collections.Generic; using System.Data.SqlClient;//引用数据库客户端 using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; using System.Data; namespace PubilcHelper { public class DBHelper { //…
create database School use School go create table Student --1.学生表 ( Sno ) not null primary key,--学号(主码) Sname ) not null,--学生姓名 Ssex ) not null,--学生性别 Sbirthday datetime,--学生出生年月 Class ),--学生所在班级 ) go create table Teacher --4.教师表 ( Tno ) not null pri…
首先创建两张表 CREATE TABLE Teacher ( Id ,) NOT NULL PRIMARY KEY, Name ) NOT NULL, ); CREATE TABLE Student ( Id ,) NOT NULL PRIMARY KEY, TeacherID INT NOT NULL FOREIGN KEY REFERENCES Teacher(Id), Name ) NOT NULL, Age INT NOT NULL, ); 一张老师表,一张学生表,关系为一对多: IDE…
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace DAL { public class SQLHelper { private SqlConnection conn =null; private SqlCo…