急!!从字符串向datetime转换时失败!!
publicinttb_EmpInfoAdd(tb_EmpInfoEmpinfo){intintFalg=0;try{stringstr_Add="insertintot...
public int tb_EmpInfoAdd(tb_EmpInfo Empinfo)
{
int intFalg = 0;
try
{
string str_Add = "insert into tb_EmpInfo values( ";
str_Add+=" '"+Empinfo.intEmpId+"','"+Empinfo.strEmpName+"','"+Empinfo.strEmpLoginName+"',";
str_Add+=" '"+Empinfo.strEmpLoginPwd+"','"+Empinfo.intEmpSex+"','"+Empinfo.daEmpBirthday+"',";
str_Add+=" '"+Empinfo.strEmpDept+"','"+Empinfo.strEmpPost+"','"+Empinfo.strEmpPhone+"',";
str_Add+=" '"+Empinfo.strEmpPhoneM+"','"+Empinfo.strEmpAddress+"',";
str_Add+=""+Empinfo.intEmpFalg+")";
getSqlConnection getConnection = new getSqlConnection();
conn = getConnection.GetCon();
cmd = new SqlCommand(str_Add,conn);
intFalg = cmd.ExecuteNonQuery();
conn.Dispose();
return intFalg;
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
return intFalg;
}
} 展开
{
int intFalg = 0;
try
{
string str_Add = "insert into tb_EmpInfo values( ";
str_Add+=" '"+Empinfo.intEmpId+"','"+Empinfo.strEmpName+"','"+Empinfo.strEmpLoginName+"',";
str_Add+=" '"+Empinfo.strEmpLoginPwd+"','"+Empinfo.intEmpSex+"','"+Empinfo.daEmpBirthday+"',";
str_Add+=" '"+Empinfo.strEmpDept+"','"+Empinfo.strEmpPost+"','"+Empinfo.strEmpPhone+"',";
str_Add+=" '"+Empinfo.strEmpPhoneM+"','"+Empinfo.strEmpAddress+"',";
str_Add+=""+Empinfo.intEmpFalg+")";
getSqlConnection getConnection = new getSqlConnection();
conn = getConnection.GetCon();
cmd = new SqlCommand(str_Add,conn);
intFalg = cmd.ExecuteNonQuery();
conn.Dispose();
return intFalg;
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
return intFalg;
}
} 展开
2个回答
展开全部
public int tb_EmpInfoAdd(tb_EmpInfo Empinfo)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int intFalg = 0;
try
{
String str_Add = "insert into tb_EmpInfo values( ";
str_Add+=" '"+Empinfo.intEmpId+"','"+Empinfo.strEmpName+"','"+Empinfo.strEmpLoginName+"',";
str_Add+=" '"+Empinfo.strEmpLoginPwd+"','"+Empinfo.intEmpSex+"','"+formatter.format(Empinfo.daEmpBirthday)+"',";
str_Add+=" '"+Empinfo.strEmpDept+"','"+Empinfo.strEmpPost+"','"+Empinfo.strEmpPhone+"',";
str_Add+=" '"+Empinfo.strEmpPhoneM+"','"+Empinfo.strEmpAddress+"',";
str_Add+=""+Empinfo.intEmpFalg+")";
getSqlConnection getConnection = new getSqlConnection();
conn = getConnection.GetCon();
cmd = new SqlCommand(str_Add,conn);
intFalg = cmd.ExecuteNonQuery();
conn.Dispose();
return intFalg;
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
return intFalg;
}
}
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int intFalg = 0;
try
{
String str_Add = "insert into tb_EmpInfo values( ";
str_Add+=" '"+Empinfo.intEmpId+"','"+Empinfo.strEmpName+"','"+Empinfo.strEmpLoginName+"',";
str_Add+=" '"+Empinfo.strEmpLoginPwd+"','"+Empinfo.intEmpSex+"','"+formatter.format(Empinfo.daEmpBirthday)+"',";
str_Add+=" '"+Empinfo.strEmpDept+"','"+Empinfo.strEmpPost+"','"+Empinfo.strEmpPhone+"',";
str_Add+=" '"+Empinfo.strEmpPhoneM+"','"+Empinfo.strEmpAddress+"',";
str_Add+=""+Empinfo.intEmpFalg+")";
getSqlConnection getConnection = new getSqlConnection();
conn = getConnection.GetCon();
cmd = new SqlCommand(str_Add,conn);
intFalg = cmd.ExecuteNonQuery();
conn.Dispose();
return intFalg;
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
return intFalg;
}
}
TableDI
2024-07-18 广告
2024-07-18 广告
在Excel中,字符串匹配函数主要用于查找和定位特定字符串在文本中的位置或进行替换操作。常用的字符串匹配函数包括FIND、SEARCH、SUBSTITUTE和REPLACE等。FIND和SEARCH函数用于查找字符串的位置,而SUBSTIT...
点击进入详情页
本回答由TableDI提供
展开全部
java的日期转String
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(Empinfo.daEmpBirthday);
你那么直接连接虽然编译通过,但实际上格式不被认识
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(Empinfo.daEmpBirthday);
你那么直接连接虽然编译通过,但实际上格式不被认识
追问
额。。。没怎么懂,具体怎么改,这个放在哪啊
追答
执行
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(Empinfo.daEmpBirthday);
然后 用dateString 替换里面的 Empinfo.daEmpBirthday
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询