标签未在用户上显示学校名称 [英] Label not showing school name on user
问题描述
我有一个从数据库中获取学校名称的代码。当用户登录系统并单击表单时,Label会显示学校的名称,城市,州。它适用于所有其他用户,但不适用于其他用户。当此用户登录并单击表单时,Label会显示用户学校名称,城市和州。当用户单击其他表单时,它不会显示。有人可以帮助我,因为它很奇怪。是的,用户在数据库中有一个配置文件,包含所有其他用户拥有的所有内容。
适用于此表单的代码:
I have a code that gets the school name from a database. When a user logs into the system and clicks on a form, the Label displays the School's Name, City, State. It works for all of the other users but not one. When this user logs in and clicks on a form the Label displays the users School Names, City and State. When the user clicks on a different form it does not display. Can someone help me with this because it is weird. And yes the user has a profile in the database with everything that all other users have.
Code that works for use on this form:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing.Printing;
namespace SACSCOCLogin1._1
{
public partial class Gradrate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Print.Attributes.Add("onclick", "window.print(); return false");
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con2.Open();
SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con3.Open();
TextBoxINST_ID.Text = Session["inst_id"].ToString();
SqlCommand scmd = new SqlCommand("Select INST_ID, LongName, City, State from TableCOCINST where INST_ID = '" + TextBoxINST_ID.Text + "'", con);
SqlCommand scmd2 = new SqlCommand("Select INST_ID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS from TableGRADRATE where INST_ID = '" + TextBoxINST_ID.Text + "'", con2);
SqlCommand scmd3 = new SqlCommand("Select INST_ID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR, DATE from TableGRADRATE where INST_ID = '" + TextBoxINST_ID.Text + "'", con3);
SqlDataReader dr = scmd.ExecuteReader();
SqlDataReader dr2 = scmd2.ExecuteReader();
SqlDataReader dr3 = scmd3.ExecuteReader();
if (dr.Read())
if (dr2.Read())
if (dr3.Read())
{
TextBoxLYTNUGSC.Text = dr2["ASTUDENTS"].ToString();
TextBoxLYTNUGSCD.Text = dr2["ACOMPLETED"].ToString();
TextBoxLYTTOUG.Text = dr2["ATRANSFERS"].ToString();
TextBoxLYTNGSC.Text = dr2["BSTUDENTS"].ToString();
TextBoxLYTNGSCD.Text = dr2["BCOMPLETED"].ToString();
TextBoxLYTTOG.Text = dr2["BTRANSFERS"].ToString();
lblSchool.Text = dr["LongName"].ToString();
lblCity.Text = dr["City"].ToString();
lblState.Text = dr["State"].ToString();
TextBoxTNUGSC.Text = dr3["ASTUDENTS"].ToString();
TextBoxTNUGSCD.Text = dr3["ACOMPLETED"].ToString();
TextBoxTTOUG.Text = dr3["ATRANSFERS"].ToString();
TextBoxTNGSC.Text = dr3["BSTUDENTS"].ToString();
TextBoxTNGSCD.Text = dr3["BCOMPLETED"].ToString();
TextBoxTTOG.Text = dr3["BTRANSFERS"].ToString();
TextBoxYEAR.Text = dr3["YEAR"].ToString();
TextBoxDATE.Text = dr3["DATE"].ToString();
}
}
此表单的代码不适用于此用户:
This form has the code that does not work for this user:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing.Printing;
public partial class FTEEnrollmentInformation : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ButtonPrint.Attributes.Add("onclick", "window.print(); return false");
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con2.Open();
SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con3.Open();
TextBoxINST_ID.Text = Session["inst_id"].ToString();
SqlCommand scmd = new SqlCommand("Select INST_ID, LongName, City, State from TableCOCINST where INST_ID = '" + TextBoxINST_ID.Text + "'", con);
SqlCommand scmd2 = new SqlCommand("Select INST_ID, FT_UNDERGR, FT_GRAD, FTE_UNDERG, FTE_GRAD, NON_CREDIT, TOTAL_FTE, FCFTUHC, FCFTPBHC, FCPTUHC, FCPTPBHC, NCHC, FTEYR from TableFTE2012 where INST_ID = '" + TextBoxINST_ID.Text + "'", con2);
SqlCommand scmd3 = new SqlCommand("Select INST_ID, FT_UNDERGR, FT_GRAD, FTE_UNDERG, FTE_GRAD, NON_CREDIT, TOTAL_FTE, FCFTUHC, FCFTPBHC, FCPTUHC, FCPTPBHC, NCHC from TableFTE2013 where INST_ID = '" + TextBoxINST_ID.Text + "'", con3);
SqlDataReader dr = scmd.ExecuteReader();
SqlDataReader dr2 = scmd2.ExecuteReader();
SqlDataReader dr3 = scmd3.ExecuteReader();
if (dr.Read())
if (dr2.Read())
if (dr3.Read())
{
TextBoxINST_ID.Text = dr["INST_ID"].ToString();
lblCity.Text = dr["City"].ToString();
lblState.Text = dr["State"].ToString();
lblSchool.Text = dr["LongName"].ToString();
lblLYear.Text = dr2["FTEYR"].ToString();
TextBoxLYFTUG.Text = dr2["FT_UNDERGR"].ToString();
TextBoxLYFTG.Text = dr2["FT_GRAD"].ToString();
TextBoxLYTHUGDR.Text = dr2["FTE_UNDERG"].ToString();
TextBoxLYTHGDR.Text = dr2["FTE_GRAD"].ToString();
TextBoxLYNCCDR.Text = dr2["NON_CREDIT"].ToString();
TextBoxLYTCNC.Text = dr2["TOTAL_FTE"].ToString();
TextBoxLYTNFUG.Text = dr2["FCFTUHC"].ToString();
TextBoxLYTNFG.Text = dr2["FCFTPBHC"].ToString();
TextBoxLYTNCPUG.Text = dr2["FCPTUHC"].ToString();
TextBoxLYTNCPG.Text = dr2["FCPTPBHC"].ToString();
TextBoxLYTNNCC.Text = dr2["NCHC"].ToString();
TextBoxINST_ID.Text = dr["INST_ID"].ToString();
TextBoxINST_ID.Text = dr["INST_ID"].ToString();
lblCity.Text = dr["City"].ToString();
lblState.Text = dr["State"].ToString();
lblSchool.Text = dr["LongName"].ToString();
TextBoxFTUG.Text = dr3["FT_UNDERGR"].ToString();
TextBoxFTG.Text = dr3["FT_GRAD"].ToString();
TextBoxTHUGDR.Text = dr3["FTE_UNDERG"].ToString();
TextBoxTHGDR.Text = dr3["FTE_GRAD"].ToString();
TextBoxNCCDR.Text = dr3["NON_CREDIT"].ToString();
TextBoxTCNC.Text = dr3["TOTAL_FTE"].ToString();
TextBoxTNFUG.Text = dr3["FCFTUHC"].ToString();
TextBoxTNFG.Text = dr3["FCFTPBHC"].ToString();
TextBoxTNCPUG.Text = dr3["FCPTUHC"].ToString();
TextBoxTNCPG.Text = dr3["FCPTPBHC"].ToString();
TextBoxTNNCC.Text = dr3["NCHC"].ToString();
}
dr.Close();
con.Close();
dr2.Close();
con2.Close();
dr3.Close();
con3.Close();
}
推荐答案
好的。我发现了我的问题。它在数据库中。我正在阅读的记录在数字末尾有一个不正确的字符。所以我把它删掉了。现在它有效。
Ok. I found my issue. It was in the database. The record I was reading had an incorrect character at the end of the number. So I deleted it off. Now It works.
这篇关于标签未在用户上显示学校名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!