• 主页
  • ASP
  • .NET Framework
  • Web Services
  • VB
  • VC
  • 图表区
  • 分析与设计
  • 组件/控件开发
  • LINQ
wodelaopos 2012年11月23日
大家帮忙看看,这段代码怎么不执行啊,也不报错
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class transformone : System.Web.UI.Page
{
public string userid = "";
public string ser = "";
public string are = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
userid = Request["username"].ToString();
//ser = Request["server"];
//are = Request["Area"];
this.bind();
}
}
protected void bind()
{
if (Request["username"].ToString()!=null||Request["username"].ToString()!="")
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ddd"].ToString());
con.Open();
SqlCommand cmd1 = new SqlCommand("select * from Gifts where userid=@userid",con);
cmd1.Parameters.Add("@userid",SqlDbType.VarChar).Value=Request["username"].ToString();
cmd1.ExecuteNonQuery();
DataTable dt = new DataTable();
dt.Load(cmd1.ExecuteReader());
if (dt.Rows.Count>0)
{
SqlCommand cmd2 = new SqlCommand("update Gifts set Treasures=@Treasures,RegisterTime=@RegisterTime where userid=@userid",con);
cmd2.Parameters.Add("@userid", SqlDbType.VarChar).Value = Request["username"].ToString();
cmd2.Parameters.Add("@Treasures", SqlDbType.VarChar).Value = "光涛信物";
cmd2.Parameters.Add("@RegisterTime", SqlDbType.DateTime).Value = DateTime.Now;
cmd2.ExecuteNonQuery();
con.Close();
}

else
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into Gifts(userid,Treasures,RegisterTime) values(@p1,@p2,@p3)", con);
cmd.Parameters.Add("@p1", SqlDbType.VarChar).Value = Request["username"].ToString();
cmd.Parameters.Add("@p2", SqlDbType.VarChar).Value = "光涛信物";
cmd.Parameters.Add("@p3", SqlDbType.DateTime).Value = DateTime.Now;
cmd.ExecuteNonQuery();
con.Close();
//Response.Redirect("PledgeFor.aspx?username="+userid);
}
}
}
}
...全文
263 点赞 收藏 19
写回复
19 条回复

还没有回复,快来抢沙发~

发动态
发帖子
.NET技术社区
创建于2007-09-28

4.8w+

社区成员

66.8w+

社区内容

.NET技术交流专区
社区公告
暂无公告