数据库
<div class="Highlighter"><pre class="brush:csharp;gutter:true;">
string source = “server=(local)\\YALI;database=CarManagementSystem;integrated security=SSPI”;
</pre></div>
1.string source = “server=(local)\\YALI;database=CarManagementSystem;integrated security=SSPI”;
或
Web.config
<configuration>
<appSettings>
<add key= “ConnectionString” value= “server=(local)\YALI;
database=CarManagementSystem;integrated security=SSPI”/>
</appSettings>
</configuration>
var source = ConfigurationManager.AppSettings[“ConnectionString”].ToString();
2.SqlConnection conn = new SqlConnection(Source);
conn.Open();
3.string insert/update/… = “sql语句”;
4.SqlCommand cmd = new SqlCommand(insert,conn);
5.SqlParameter sql1 = new SqlParameter(“@UserName”, Uname);
cmd.Parameters.Add(sql1);
6.cmd.ExecuteNonQuery();cmd.ExecuteQuery();cmd.ExecuteReader();cmd.ExecuteScalar();
cmd.EndExecuteXmlReader();
conn.Close();
1~6封装与Model中
Microsoft SQL Server 2014
SQL Server 2014 Management Studio
主键 Primary Key
自增Identity Specification-→(IS Identity):Yes
Tools-→Options-→Designers-→Prevent==>Design
(1)NOT IN (‘’, ‘’, ‘’)
(2)SQL语句中,集合类不可使用SqlDbType转换,此时以NOT IN举例:
直接 “NOT IN(” + 集合类(<string>) + “)”;
首字母大写
UPPER(LEFT(?,1))+LOWER(RIGHT(?,LEN(?)-1)) AS
大写 左起 1个 小写 右起 长度-1 个
CONVERT(VARCHAR(100),getdate(),111) 无00:00:00
创建views内数据库
1.右击Views文件夹-→New View-->X掉
2.Select (1)写
==>运行查看==>保存命名:vw~~
From (2)写
(查看==>Views内任意数据库==>右击Design)
(1) *
(2) DataURD.dbo.名字
原文:https://www.cnblogs.com/jscxt/p/12179931.html