private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConStr"]);
if(this.DropDownList1.SelectedItem.Text!="所有人")
{
Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,this.DropDownList1.SelectedItem.Text,getname(),this.Page.Request.UserHostAddress);
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
else
{
string comstr="select xinming from login";
con.Open();
SqlCommand cmd=new SqlCommand(comstr,con);
SqlDataReader dr=cmd.ExecuteReader();
for(int i=1;i<=DataBase.GetUserCount();i++)
{
// Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,dr[i].ToString(),getname(),this.Page.Request.UserHostAddress);
this.Label1.Text=dr[i].ToString();
}
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
}
代码如上
意思就是说统计login表中数据的条数 然后循环发送 达到发送给所有人的目的
我知道以上代码有问题 谁帮我修改下 ~~谢谢!
{
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConStr"]);
if(this.DropDownList1.SelectedItem.Text!="所有人")
{
Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,this.DropDownList1.SelectedItem.Text,getname(),this.Page.Request.UserHostAddress);
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
else
{
string comstr="select xinming from login";
con.Open();
SqlCommand cmd=new SqlCommand(comstr,con);
SqlDataReader dr=cmd.ExecuteReader();
for(int i=1;i<=DataBase.GetUserCount();i++)
{
// Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,dr[i].ToString(),getname(),this.Page.Request.UserHostAddress);
this.Label1.Text=dr[i].ToString();
}
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
}
代码如上
意思就是说统计login表中数据的条数 然后循环发送 达到发送给所有人的目的
我知道以上代码有问题 谁帮我修改下 ~~谢谢!
private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConStr"]);
if(this.DropDownList1.SelectedItem.Text!="所有人")
{
Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,this.DropDownList1.SelectedItem.Text,getname(),this.Page.Request.UserHostAddress);
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
else
{
string comstr="select xinming from login";
con.Open();
SqlCommand cmd=new SqlCommand(comstr,con);
SqlDataReader dr=cmd.ExecuteReader();
where(dr.Read())
{
//Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,dr[0].ToString(),getname(),this.Page.Request.UserHostAddress);
this.Label1.Text=dr[0].ToString();
}
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConStr"]);
if(this.DropDownList1.SelectedItem.Text!="所有人")
{
Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,this.DropDownList1.SelectedItem.Text,getname(),this.Page.Request.UserHostAddress);
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
else
{
string comstr="select xinming from login";
con.Open();
SqlCommand cmd=new SqlCommand(comstr,con);
SqlDataReader dr=cmd.ExecuteReader();
while(dr.Read())
{
//Message.Sendsms(this.TextBox2.Text,this.TextBox1.Text,dr[0].ToString(),getname(),this.Page.Request.UserHostAddress);
this.Label1.Text=dr[0].ToString();
}
Response.Write("<script>alert('消息已成功发送!');window.location.href='./sendsms.aspx';</script>");
}
}