| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4078 人关注过本帖
标题:"将截断字符串或二进制数据,语句已结束“
取消只看楼主 加入收藏
水晶之恋
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2007-4-23
收藏
 问题点数:0 回复次数:0 
"将截断字符串或二进制数据,语句已结束“

1."将截断字符串或二进制数据,语句已结束"
2."从char数据类型到datetime数据类型的转换导致datetime值越界,语句已终止"
----哪里会有从char到datetime的转换啊?

数据库:
users_id bigint 8
username nvarchar 20
sex char 10
hometown nvarchar 50
nation char 10
birth datetime 8
health char 10 允许为空
marry nvarchar 50 允许为空
political nvarchar 50 允许为空
address nvarchar 50 允许为空
mobilephone nvarchar 12 允许为空
homephone nvarchar 12 允许为空
email nvarchar 12 允许为空
gra_school nvarchar 50 允许为空
zhuanye nvarchar 50 允许为空
xueli nvarchar 50 允许为空
gra_time datetime 8 允许为空
work_time datetime 8 允许为空
PicUrl image 16 允许为空
dep_id char 10
...

private void addperson_Click(object sender, System.EventArgs e)
{
if (myFile.PostedFile.ContentLength != 0)
{
if (myFile.PostedFile != null)
{
string nam = myFile.PostedFile.FileName;
int i = nam.LastIndexOf(".");
newext = nam.Substring(i);
DateTime now = DateTime.Now;
newname = now.DayOfYear.ToString() + myFile.PostedFile.ContentLength.ToString();
filename = "\\" + newname + newext;
myFile.PostedFile.SaveAs(Server.MapPath(Request.ApplicationPath) + "\\pic" + filename);
url="\\pic" + filename;
}
}
string strsql;
strsql="insert into users(username,sex,hometown,nation,birth,health,marry,political,address,mobilephone,homephone,email,gra_school,zhuanye,xueli,gra_time,work_time,dep_id,zhiwu,type,constract_time,cancel_time,PicUrl) values(";
strsql+="'" + username.Text + "',";
strsql+="'" + sex.SelectedValue + "',";
strsql+="'" + hometown.Text + "',";
strsql+="'" + nation.Text + "',";
strsql+="'" + birth.Text + "',";
strsql+="'" + health.Text + "',";
strsql+="'" + marry.SelectedValue + "',";
strsql+="'" + political.Text + "',";
strsql+="'" + address.Text + "',";
strsql+="'" + mobilephone.Text + "',";
strsql+="'" + homephone.Text + "',";
strsql+="'" + email.Text + "',";
strsql+="'" + gra_school.Text + "',";
strsql+="'" + zhuanye.Text + "',";
strsql+="'" + xueli.SelectedValue + "',";
strsql+="'" + gra_time.Text + "',";
strsql+="'" + work_time.Text + "',";
strsql+="'" + dep_name.SelectedValue + "',";
strsql+="'" + zhiwu.Text + "',";
strsql+="'" + type.SelectedValue + "',";
strsql+="'" + constract_time.Text + "',";
strsql+="'" + cancel_time.Text + "',";
strsql+="'" + url + "')";

com=new SqlCommand(strsql,conn);
conn.Open();
com.ExecuteNonQuery();
conn.Close();
Response.Write("<script>javascript:alert('添加成功!!!');window.location='default.aspx'</script>");
}

搜索更多相关主题的帖子: 二进制数据 语句 nvarchar 数据库 字符 
2007-05-18 11:45
快速回复:"将截断字符串或二进制数据,语句已结束“
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016884 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved