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

1.JPG (31.05 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
2008-04-12 21:43
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.022922 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved