初学.net,简单问题请教
我要做登陆界面,可目前没法获取到界面上的UserName与Password值
因为本人没有任何C#的基础,只会一点asp,所以搜索了类似的问题,仍然不果...
请各位大人多多指教
以下是界面的代码
<%@ Page Language= "C# " %>
<%@ import Namespace= "System.Data " %>
<%@ import Namespace= "System.Data.SqlClient " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "server ">
protected void LoginButton_Click(object sender, EventArgs e)
{
SqlConnection Myconn = new SqlConnection();
string User = Request[ "UserName "];
//尝试了好几种方式都不行,不知道错是在获取的方法上还是根本就没有传递?
string Pwd = Request.Form.Get( "Password ");
string Constr = "server=xx;uid=xx;pwd=xx;database=xx;Connect Timeout=30 ";
string Sql = "sp_Employee_Login " + User + ", " + Pwd;
Myconn = new SqlConnection(Constr);
SqlCommand Strsql = new SqlCommand(Sql, Myconn);
Response.Write(User);
try
{
Myconn.Open();
SqlDataReader rs = Strsql.ExecuteReader(0);
if (rs.GetValue(0) != null)
{
Response.Redirect( "~data.asp ");
}
if (rs!= null)
{ rs.Close(); }
}
catch(
System.Exception ex)
{
this.Response.Write( "Logged failed ");
}
finally
{
if (Myconn!=null)
{
Myconn.Close();