[entity framework ] The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
摘要:One of the common error people face, when they useEntity Framework, is the exception"The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value."thrown. This occurs when the entity associated with the table being saved has a mandatory datetime field a
阅读全文
posted @
2013-01-14 16:35
露水丛生
阅读(531)
推荐(0) 编辑
LINQ to Entities已知问题及注意事项
摘要:1)EXception“无法创建类型为“XX类型”的常量值。此上下文中仅支持基元类型或枚举类型不支持引用非标量闭包不支持在查询中引用非标量闭包(如实体)。在执行这类查询时,会引发NotSupportedException异常,并显示消息“无法创建类型为“结束类型”的常量值。此上下文中仅支持基元类型(‘如Int32、String和Guid’)如下将会报异常的代码:using(varedm =newNorthwindEntities()){Customerscustomer = edm.Customers.FirstOrDefault();IQueryable<string> cc =
阅读全文
posted @
2012-08-15 11:02
露水丛生
阅读(1598)
推荐(0) 编辑
varchar和Nvarchar区别
摘要:Unicode字符集就是为了解决字符集这种不兼容的问题而产生的,它所有的字符都用两个字节表示,即英文字符也是用两个字节表示如果还为了这个纠结,就直接看看后面的解说,做决定吧。一般如果用到中文或者其它特殊字符,我就会使用n开头的类型,否则的话直接使用var开头的。sql server中的varchar和Nvarchar有什么区别?答:varchar(n)长度为 n 个字节的可变长度且非 Unicode 的字符数据。n 必须是一个介于 1 和 8,000 之间的数值。存储大小为输入数据的字节的实际长度,而不是 n 个字节。nvarchar(n)包含 n 个字符的可变长度 Unicode 字符数据。
阅读全文
posted @
2012-08-01 10:15
露水丛生
阅读(179)
推荐(1) 编辑
违反了PRIMARY KEY约束不能在对象中插入重复 + 当IDENTITY_INSERT 设置为 OFF 时,不能向表 中的标识列插入显式值。
摘要:违反了PRIMARY KEY约束不能在对象中插入重复情景描述: 先插入一条订单记录到Orders表中,然后一条条插入要购买的产品条目到OrderItems表中,然而OrderItems表并未设置主键自增长未设置表OrderItems主键为自增长,而自己在插入一条记录时又为给主键设置一个唯一值之后又导致了以下问题:当IDENTITY_INSERT 设置为 OFF 时,不能向表 中的标识列插入显式值。由于使用的数据库增删改操作语句是使用LINQ-SQL生成的,当更改了OrderItems表的主键为子增长的后忘了重新生成LINQ-SQL数据库映射文件的操作语句,而向OrderItems表插入一条记录
阅读全文
posted @
2011-05-04 12:24
露水丛生
阅读(2675)
推荐(0) 编辑
将截断字符串或二进制数据。语句已终止
摘要:由于待插入数据库中表的某个字段值长度大于这个相应字段在表中所定义的字段长度1 造成这个问题一般是由于表中这个字段长度定义的确太小了,增大字段大小2 例外一个很可能的原因 可能表字段设置的大小合适 不过就是获取的输入值没合法检查 夹杂一些字符(如"\n \n \n"),导致这个要插入的字段长度超出,单步调试检查这个字段的字段值就能发现比如 我在获取一项产品颜色值得到的就是 "\n \n \n 蓝色 \n ",在客户端获取值传给后台代码先检查下,加上 string.trim()之类去掉不必要的字符即可解决办法当然有多种,一是修改数据库字段大小;二是加强数据强
阅读全文
posted @
2011-05-04 12:10
露水丛生
阅读(5284)
推荐(0) 编辑
获取DataSet中某行某列的数据
摘要:LabelText=DataSet11.Tables("COMM.USERS").Rows[0]["User_Name"].tostring()LabelText = DataSet11.Tables("COMM.USERS").Rows(0).Item("user_name")Label.Text=ds.Tables(0).Rows(i).Item( "列名 ")Label.Text=ds.tables[0].rows[0][ "filed "]Label.Text=ds.Tables[0].Rows[x][y]
阅读全文
posted @
2010-12-16 19:43
露水丛生
阅读(2200)
推荐(0) 编辑
错误 SQL TOP子句中的行数必须是整数
摘要:sql = "select top "+PageSize.ToInt32() +" * from TABLE where id not in(select top " + Convert.ToInt32((pageno-1)*PageSize) +" id from TABLE)";示例:
阅读全文
posted @
2010-12-06 11:54
露水丛生
阅读(927)
推荐(0) 编辑
[网络收集]按标题进行站内搜索
摘要:MasterPage.master<div id="menu_search"> <span class="item_title">文章搜索</span> <div id="menu_search_info" class="item_info"> <center> <asp:TextBox ID="text_sea...
阅读全文
posted @
2010-11-28 23:08
露水丛生
阅读(280)
推荐(0) 编辑
[网络收集]VS2005调试问题和技巧
摘要:vs2005调试问题及解决方案锦集==============================================================================================1.检测到有潜在危险的 Request.Form 值2.“在没有任何数据时进行无效的读取尝试”解决办法3.数据为空。不能对空值调用此方法或属性。4.阅读器...
阅读全文
posted @
2010-11-28 22:06
露水丛生
阅读(664)
推荐(0) 编辑
[网络收集]sql在不同数据库查询前几条数据
摘要:1. ORACLE SELECT * FROM TABLE1 WHERE ROWNUM<=N HQL: from table1 t order by t.createTime desc where rownum<=n2. INFORMIX SELECT FIRST N * FROM TABLE1 3. DB2 SELECT * ROW_NUMBER() OVER(ORDER BY...
阅读全文
posted @
2010-11-28 21:46
露水丛生
阅读(966)
推荐(0) 编辑
[网络收集]ASP.NET中调用存储过程带(输入/输出)参数和返回值的一些常用的例子
摘要:有些初学者在调用存储过程时容易出现一些错误,下面我就不同的返回参数而言举个用户登录常用的例子做一些简单的讨论:(由简单--->>深入)创建数据库:(Student)创建用户表:(Users)use Studentgocreate table Users ( id int identity(1, 1) primary key, name nvarchar(20) not nu...
阅读全文
posted @
2010-11-14 23:22
露水丛生
阅读(528)
推荐(0) 编辑
[网络收集]ASP.NET封装的SQL数据库访问类(带存储过程)
摘要:using System;using System.Configuration;using System.Data;using System.Data.SqlClient;using System.Collections;namespace MyCorporation.DepartMent.DataBase{ /// <summary> /// 通用数据库类 /// </summ...
阅读全文
posted @
2010-11-12 20:50
露水丛生
阅读(292)
推荐(0) 编辑
[网络收集]ASP.NET操作SQL数据库封装的常用操作
摘要:using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using ...
阅读全文
posted @
2010-11-12 20:39
露水丛生
阅读(271)
推荐(0) 编辑
[网络收集]DBHelper 常用数据库连接类
摘要:using System;using System.Collections.Generic;using System.Text;using System.Data;using System.Data.SqlClient;using System.Configuration;namespace DAL{ public static class DBHelper { private static...
阅读全文
posted @
2010-11-12 20:33
露水丛生
阅读(230)
推荐(0) 编辑
存储过程之——调用带有输入和输出参数的存储过程
摘要:摘自:http://hi.baidu.com/281305450/blog/item/e70cc344f714128cb3b7dc64.html存储过程检测用户名是否重复create proc checklogin@username nchar(20),@pwd nchar(20),@hasrow int outputasselect @hasrow=count(*) from users whe...
阅读全文
posted @
2010-11-12 14:14
露水丛生
阅读(1169)
推荐(0) 编辑
Datalist高效分页代码(不用存储过程)
摘要:首先创建一张表(要求ID自动编号):create table redheadedfile ( id int identity(1,1), filenames nvarchar(50), senduser nvarchar(50), primary key(id) ) 然后我们写入50万条记录: declare @i int set @i=1 while @i<=500000 begin in...
阅读全文
posted @
2010-11-12 14:08
露水丛生
阅读(303)
推荐(0) 编辑