以下是后台代码,前台是按编号和姓名来查询自己的工资,当我单击前台查询的时候,为什么没有数据显示出来的?只是显示没有权限或输入错误?请问是错在哪里 了?谢谢~~using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class user_usersalary : System.Web.UI.Page
{
public void bind()
{
string strsql;
if (this.TextBox2.Text != "")
{
strsql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary where realname='" + this.TextBox2.Text + "'and level='一般用户'and username='" + Convert.ToString(Session["username"]) + "'";
}
else if (this.TextBox1.Text != "")
{
strsql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary where bianhao='" + this.TextBox1.Text + "'and level='一般用户'and username='" + Convert.ToString(Session["username"]) + "'";
}
else
{
Response.Write("<script>alert('您没有权限或输入错误!');history.back()</script>");
return;
}
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlDataAdapter sda = new SqlDataAdapter(strsql, strcon);
DataSet ds = new DataSet();
sda.Fill(ds, "rs_salary");
GV.DataSource = ds.Tables["rs_salary"];
GV.DataBind();
}
public void bd()
{
string sql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary ";
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds, "gzcx");
GV.DataSource = ds.Tables["gzcx"];
GV.DataBind();
con.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.TextBox1.Focus();
this.TextBox1.Text = "";
}
}
protected void GV_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GV.PageIndex = e.NewPageIndex;
this.bd();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
this.bind();
this.TextBox1.Text = "";
this.TextBox2.Text = "";
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class user_usersalary : System.Web.UI.Page
{
public void bind()
{
string strsql;
if (this.TextBox2.Text != "")
{
strsql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary where realname='" + this.TextBox2.Text + "'and level='一般用户'and username='" + Convert.ToString(Session["username"]) + "'";
}
else if (this.TextBox1.Text != "")
{
strsql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary where bianhao='" + this.TextBox1.Text + "'and level='一般用户'and username='" + Convert.ToString(Session["username"]) + "'";
}
else
{
Response.Write("<script>alert('您没有权限或输入错误!');history.back()</script>");
return;
}
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlDataAdapter sda = new SqlDataAdapter(strsql, strcon);
DataSet ds = new DataSet();
sda.Fill(ds, "rs_salary");
GV.DataSource = ds.Tables["rs_salary"];
GV.DataBind();
}
public void bd()
{
string sql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary ";
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds, "gzcx");
GV.DataSource = ds.Tables["gzcx"];
GV.DataBind();
con.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.TextBox1.Focus();
this.TextBox1.Text = "";
}
}
protected void GV_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GV.PageIndex = e.NewPageIndex;
this.bd();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
this.bind();
this.TextBox1.Text = "";
this.TextBox2.Text = "";
}
}
解决方案 »
- 请教JSON问题
- SQL存储过程的返回值类型?
- 关于前台取值后台用的问题!Repeater的值!请高手,问题听难!急!在线等!求好心人!
- 登录失败。详细资料: crdb_adoplus : 未将对象引用设置到对象的实例。文件 C:\DOCUME~1\SUISUI~1\LOCALS~1\Temp\CrystalReport1 {65A83A
- 有关使用.net打包后文件不能安装的问题
- 请人开发一个ASP.net的rss聚合,有意者进~~~~~
- 一条SQL语句strquery="select adx_name As Text from adx as TreeNode for xml auto,XMLDATA"
- WEB的开发已做了两年了,我要转到Windows的开发,应该怎么去学?
- windows server 2008系统 运行.net 程序停止运行 出现clr20r3问题
- 新手,这个小功能怎么做
- StreamWriter streamWriter = new StreamWriter(Response.OutputStream);提问
- 求一个ibatisnet的项目
{
strsql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary where realname='" + this.TextBox2.Text + "'and level='一般用户'and username='" + Convert.ToString(Session["username"]) + "'";
//绑定
}
else if (this.TextBox1.Text != "")
{
strsql = "select bianhao,realname,empl_pays,empl_zcpay,empl_age,empl_zw,empl_bufa,empl_jt,empl_hsf,empl_flj,empl_jbf,empl_ydf,empl_jj,empl_other,empl_qq,empl_lbf,empl_bxf,empl_cf,empl_jzkh,empl_sds,empl_ykgz,empl_sfgz,empl_info from rs_salary where bianhao='" + this.TextBox1.Text + "'and level='一般用户'and username='" + Convert.ToString(Session["username"]) + "'";
//绑定
}
else
{
Response.Write("<script>alert('您没有权限或输入错误!');history.back()</script>");
}