private void gridviewbind()
{
SqlConnection myConn = new SqlConnection(connStr);
string S5 = Request.QueryString["a"];
DateTime S1 = Convert.ToDateTime(S5);
string S2 = Request.QueryString["b"];
string S3 = Request.QueryString["c"];
string S4 = Request.QueryString["d"];
SqlDataAdapter myDa = new SqlDataAdapter("select * from V4 where 时间='" + S1 + "&收银员" + S2 + "&商品种类" + S3 + "&品名" + S4 +"'", myConn);
myConn.Open();
DataSet myDataSet = new DataSet();
myDa.Fill(myDataSet);
GridView1.DataSource = myDataSet.Tables[0];
GridView1.DataBind();
myConn.Close();
}
错误:从字符串转换日期和/或时间时,转换失败
这个怎么解决
求助,总是出现从字符串转换日期和/或时间时,转换失败这个错误
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答
- 南宫文凯 2017-06-21 02:38关注
public static String dataToString(java.util.Date dt, String type) {
String returnStr = null;
if (dt == null) {
return null;
} else {
// YYYY-MM-DD HH24:MI:SS
type = StringUtil.StringReplace("YYYY", "yyyy", type);
type = StringUtil.StringReplace("DD", "dd", type);
type = StringUtil.StringReplace("SS", "ss", type);
type = StringUtil.StringReplace("hh24", "HH", type);
type = StringUtil.StringReplace("HH24", "HH", type);
type = StringUtil.StringReplace("MI", "mm", type);
type = StringUtil.StringReplace("mi", "mm", type);
}
if (type == null || type.trim().equals("")) {
returnStr = DateFormat.getDateTimeInstance().format(dt);
} else {
SimpleDateFormat f = new SimpleDateFormat(type);
returnStr = f.format(dt);
}
return returnStr;
}* 转换的格式类型可以自行定义(其中年yyyy月MM日dd时HH分mm秒ss):<br> * (1)转换成yyyy-MM-dd HH:mm:ss格式:2005-5-25 10:50:24<br> * (2)转换成yyyy年MM月dd日 HH:mm:ss格式:2005年5月25日 10:50:24<br> * (3)转换成yyyyMMddHHmmss格式:20061024152356<br> * (4)转换成yyyy-MM-dd格式:2006-12-11<br> * (5)转换成yyyyMMdd格式:20061211<br> * (5)转换成yyyyMM格式:200612<br> * (6)转换类型null时,格式默认为yyyy-MM-dd HH:mm:ss
解决 无用评论 打赏 举报
悬赏问题
- ¥15 为什么eprime输出的数据会有缺失?
- ¥20 腾讯企业邮箱邮件可以恢复么
- ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
- ¥15 错误 LNK2001 无法解析的外部符号
- ¥50 安装pyaudiokits失败
- ¥15 计组这些题应该咋做呀
- ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
- ¥15 让node服务器有自动加载文件的功能
- ¥15 jmeter脚本回放有的是对的有的是错的
- ¥15 r语言蛋白组学相关问题