0
Я пытаюсь получить данные пользователя из моей базы данных в журнале, и для этого я получаю идентификатор login из текстового поля формы входа и помещен в метку.Должен объявить скалярную переменную «@CID»
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
TextBox SourceTextBox =
(TextBox)PreviousPage.FindControl("TextBox1");
if (SourceTextBox != null)
{
Label1.Text = SourceTextBox.Text;
string CID = Label1.Text;
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string CID = Label1.Text;
string ConStr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["SMSCon"].ConnectionString;
SqlConnection con = new SqlConnection(ConStr);
SqlCommand cmd = new SqlCommand("select StudentID, StudentName, StudentClass, StudentGender, StudentDob, StudentFatherName, StudentPhone, StudentAddress, StudentLogin, StudentPassword from TblStudent where [email protected]", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
}
Спасибо! Работает... –