摘要: 在"ASP.NET MVC与Sql Server交互, 插入数据"中,在Controller中拼接sql语句。比如: _db.InsertData("insert into Product(Name,quantity,Price) values('"+productVm.Name+"','"+productVm.Quantity+"','"+productVm.Price+"')"); ... 阅读全文
posted @ 2015-07-06 21:56 Darren Ji 阅读(2867) 评论(1) 推荐(1)
摘要: 在"ASP.NET MVC与Sql Server建立连接"中,与Sql Server建立了连接。本篇实践向Sql Server中插入数据。 在数据库帮助类中增加插入数据的方法。 public class SqlDB { protected SqlConnection conn; //打开连接 public bool OpenC... 阅读全文
posted @ 2015-07-06 18:40 Darren Ji 阅读(5990) 评论(2) 推荐(3)
摘要: 用惯了使用Entity Framework连接数据库,本篇就来体验使用SqlConnection连接数据库。 打开Sql Server 2008,创建数据库,创建如下表: create table Product ( Id int identity(1,1) not null primary key, Name nvarchar(50) null, quantity ... 阅读全文
posted @ 2015-07-06 17:10 Darren Ji 阅读(19261) 评论(4) 推荐(3)

我的公众号:新语新世界,欢迎关注。