主题:为什么你总是选择失败?
private void Button1_Click(object sender, System.EventArgs e)
{
string user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString();
System.DateTime currentTime=new System.DateTime();
string strYMD=currentTime.ToString("D");
string strT=currentTime.ToString("t");
string strSql="insert into SignUser(WorkNumber,workType1,Time,Ip,Date) values('" + TextBox1.Text.Trim() +"','"+DropDownList1.SelectedItem.Text +"','"+ strT +"','"+ user_IP +"','"+ strYMD +"')";
OleConnString = new OleDbConnection(strOleSqlConn);
Response.Write(strSql);
OleDbCommand OleComm = new OleDbCommand(strSql,OleConnString);
OleConnString.Open();
Response.Write(OleComm.ExecuteNonQuery());
try
{
if(OleComm.ExecuteNonQuery()>0)
{
Response.Write("<script language=javascript>alert('签到成功!');</script>");
}
else
{
Response.Write("<script language=javascript>alert('签到失败!');</script>");
}
}
catch
{
Response.Write("<script language=javascript>alert('签到失败!');</script>");
}
finally
{
OleConnString.Close();
}
}//请各位高手看看我的程序为什么总是走到catch语句
{
string user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString();
System.DateTime currentTime=new System.DateTime();
string strYMD=currentTime.ToString("D");
string strT=currentTime.ToString("t");
string strSql="insert into SignUser(WorkNumber,workType1,Time,Ip,Date) values('" + TextBox1.Text.Trim() +"','"+DropDownList1.SelectedItem.Text +"','"+ strT +"','"+ user_IP +"','"+ strYMD +"')";
OleConnString = new OleDbConnection(strOleSqlConn);
Response.Write(strSql);
OleDbCommand OleComm = new OleDbCommand(strSql,OleConnString);
OleConnString.Open();
Response.Write(OleComm.ExecuteNonQuery());
try
{
if(OleComm.ExecuteNonQuery()>0)
{
Response.Write("<script language=javascript>alert('签到成功!');</script>");
}
else
{
Response.Write("<script language=javascript>alert('签到失败!');</script>");
}
}
catch
{
Response.Write("<script language=javascript>alert('签到失败!');</script>");
}
finally
{
OleConnString.Close();
}
}//请各位高手看看我的程序为什么总是走到catch语句