窗体之间传递数据
登陆代码中在form1中有这条df = "select stuNO,stuPwd from info_stu where stuNO='" & id & "' and stuPwd='" & pwd & "'"语句,我想通过单击btnYes验证成功后,跳转到form2,在form2中有个label,我希望stuNO的值能显示在label中。表述不是很清楚希望大家谅解 --------------------编程问答-------------------- in form1: form2 frm = new form2(stuNO);
in form2:
private string stuNo;
public form2(string stuNo)
{
this.stuNo = stuNo;
}
lable.text = stuNo; --------------------编程问答-------------------- LS是C#么? --------------------编程问答-------------------- 没看明白LZ的意思-。-# --------------------编程问答-------------------- 修改form2的构造函数,实例化传入你的id 和pwd --------------------编程问答-------------------- 各位老大们, 麻烦你们说通俗点嘛, 做为新手的我看不懂啊,小弟在次先谢谢了啊
--------------------编程问答-------------------- "我希望stuNO的值能显示在label中" 是stuNO还是id?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim form2 As New Form2
form2.Show()
form2.Label1.Text = id
End Sub --------------------编程问答-------------------- 不好意思没说清楚, 我是想验证id是否存在,存在且密码正确登陆成功,并把id 所对应的stuNO(学号),stuName(姓名),显示在form2 的label中,让大家误会不好意思了
希望快点回帖,等到用,谢谢 --------------------编程问答-------------------- Dim Conn As OleDbConnection
Dim Cmd As OleDbCommand
Dim Rd As OleDbDataReader, SQL As String
Dim Provider = "Provider=Microsoft.Jet.OLEDB.4.0"
Dim Database = "Data Source=" & Application.StartupPath() & "\login.mdb"
Conn = New OleDbConnection(Provider & ";" & Database)
Conn.Open()
SQL = "Select * From admin Where 用户名='" & user.Text & "' And 密码='" & pass.Text & "'"
Cmd = New OleDbCommand(SQL, Conn)
Rd = Cmd.ExecuteReader()
If Rd.Read() Then ' 表示有找到通过验证
'MessageBox.Show("成功", "ok!")
Dim form2 As New Form2
form2.Show()
form2.Label1.Text = Rd.Item("stuNO") & " " & Rd.Item("stuName")
Else
MessageBox.Show("密码或用户名错误!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Rd.Close()
Conn.Close()
补充:.NET技术 , VB.NET