| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1036 人关注过本帖
标题:字符串转换成datetime类型时发生语法错误
只看楼主 加入收藏
doujiang
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2008-4-7
收藏
 问题点数:0 回复次数:4 
字符串转换成datetime类型时发生语法错误
我在表里的字段类型是datetime的
Convert.ToDateTime(txtbirth.Text)怎么会发生错误呢?
搜索更多相关主题的帖子: datetime 语法 字符 类型 Convert 
2008-04-12 20:58
hebingbing
Rank: 6Rank: 6
来 自:黄土高坡
等 级:贵宾
威 望:27
帖 子:3417
专家分:371
注 册:2007-10-22
收藏
得分:0 
出现的错误是什么啊……
应该对吧?
2008-04-12 21:19
doujiang
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2008-4-7
收藏
得分:0 
错误提示

1.JPG (31.05 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
2008-04-12 21:43
hebingbing
Rank: 6Rank: 6
来 自:黄土高坡
等 级:贵宾
威 望:27
帖 子:3417
专家分:371
注 册:2007-10-22
收藏
得分:0 
应该没有错误吧……
我记得是可以的啊……
要不你换成DateTime.Parse(TextBox1.Text)试试,要是还不行你把你的代码贴出来看看……
2008-04-12 22:05
doujiang
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2008-4-7
收藏
得分:0 
还是解决不了,字段比较多
string ConnString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionSql"];
            //从<AppSettings>节读取连接字符串     
SqlConnection sqlcon = new SqlConnection(ConnString);
//创建SqlConnection对象
sqlcon.Open();
string sqlinsert="insert into jmxx values('txthkno.Text.ToString()','txtid.Text.ToString()',"
+"'txtbno.Text.ToString()','txthno.Text.ToString()',"
+"'Drophktype.SelectedItem.Value ',"
+"'txtname.Text.ToString()',"
+"'txttel.Text.ToString()',"
+"'txtaddress.Text.ToString()',"
+"'Convert.ToInt32(txtcount.Text)',"
+"'Convert.ToInt32(txtmancount.Text)',"
+"'Convert.ToInt32(txtwomancount.Text)',"
+"'Convert.ToInt32(txtincome.Text)',"
+"'Dropeconomy.SelectedItem.Value',"
+"'Drophousetype.SelectedItem.Value',"
+"'txtfamilynote.Text.ToString()',"
+"'txtname.Text.ToString()',"
+"'txtprename.Text.ToString()',"
+"'Droprelation.SelectedItem.Value',"
+"'txtcardid.Text.ToString()',"
+"'txtsign.Text.ToString()',"
//+"'Convert.ToDateTime(txtsigndate.Text)',"
+"' DateTime.Parse(txtsigndate.Text)',"日期类型的
+"' DateTime.Parse(txtbirth.Text)',"日期类型的
//+"'Convert.ToDateTime((TextBox)(txtbirth.Text))',"
+"'txtbirthplace.Text.ToString()',"
+"'Dropsex.SelectedItem.Value',"
+"'Convert.ToInt32(txthigh.Text)',"
+"'Dropbloodtype.SelectedItem.Value',"
+"'Dropnation.SelectedItem.Value',"
+"'txthkplace.Text.ToString()',"
+"'txtjg.Text.ToString()',"
+"'Dropschool.SelectedItem.Value',"
+"'Dropmarry.SelectedItem.Value',"
+"'Droppolitical.SelectedItem.Value',"
+"'txtwork.Text.ToString()',"
+"'Dropmilitary.SelectedItem.Value',"
+"'TextBoxtel.Text.ToString()',"
+"'TextBoxnote.Text.ToString()',"
//+"'Convert.ToDateTime(txtintime.Text)',"
 +"' DateTime.Parse(txtintime.Text)',"日期类型的
 +"'txtpre.Text.ToString()',"
+"'txtinreason.Text.ToString()',"
 +"' DateTime.Parse(txtouttime.Text)',"日期类型的
//+"'Convert.ToDateTime(txtouttime.Text)',"
      +"'txtout.Text.ToString()','txtoutreason.Text.ToString()')";
SqlCommand comm = new SqlCommand(sqlinsert,sqlcon);
    comm.ExecuteNonQuery();
    sqlcon.Close();
    Response.Redirect("admin.aspx");
2008-04-12 22:24
快速回复:字符串转换成datetime类型时发生语法错误
数据加载中...
 
   



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

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