引用自定义命名控件无效的奇怪问题???
解决方案CTERP_OUT中自定义类库DAL,里面包含文件DataGet.cs,要在界面的后台文件中引用DataGet.cs中的方法,可是我在后台文件中using CTERP_OUT.DAL后并不能找到Dal中的方法,已经确定web文件依赖和引用了dal了, 源码如下,求助!!!
以下为自定义类库:
using System;
using System.Text;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace CTERP_OUT.DAL
{
public class DataGet
{
SqlDataAdapter CmdAdp;
DataTable myTable;
SqlConnection myConnection;
DataSet myDs;
public DataGet()
{
myConnection = new SqlConnection(ConfigurationSettings.AppSettings[ "ConnectionString "]);
CmdAdp = new SqlDataAdapter();
myTable = new DataTable();
myDs = new DataSet();
}
public String Login(String UserId, String PWD)
{
//SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings[ "ConnectionString "]);
SqlCommand myCommand = new SqlCommand( "ErpLogin ", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parameterLoginID = new SqlParameter( "@UserId ", SqlDbType.VarChar, 50);
parameterLoginID.Value = UserId;
myCommand.Parameters.Add(parameterLoginID);
SqlParameter parameterPassword = new SqlParameter( "@PWD ", SqlDbType.VarChar, 50);
parameterPassword.Value = PWD;
myCommand.Parameters.Add(parameterPassword);
SqlParameter parameterReason = new SqlParameter( "@reason ", SqlDbType.VarChar, 50);
parameterReason.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(parameterReason);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
string Result;
if (parameterReason.Value.ToString() == "ok ")
Result = "成功登录 ";
else if (parameterReason.Value.ToString() == "noEmp ")
{
Result = "用户名错误 ";
}
else if (parameterReason.Value.ToString() == "pError ")
{
Result = "密码错误 ";
}
else
{
Result = "帐号被禁用 ";
}
string CheckLogin;
CheckLogin = Result;
return CheckLogin;
}
}
}
以下为后台文件,其中应用了自定义类库,我想将AloginUsr 定义为Dal中的DataGet,可并不能找该方法。
using System;
using System.Data;
using System.Configuration;
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 CTERP_OUT.DAL;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void butLogin_Click(object sender, EventArgs e)
{
AloginUsr = new DataGet();
String strLoginID = txtUsername.Text.Trim();
String strPassword = txtPassword.Text.Trim();
string strReason;
string strUserID;
string strValid;
string[] NewLogin;
String[] strLoginflag = AloginUsr.Login(strLoginID, strPassword);
//登陆错误处理
if (strLoginflag[0] == "usererror " || strLoginflag[0] == "pwderror " || strLoginflag[0] == "noacount ")
{
}
else
{
}
}
}
[解决办法]
你没有实例化
或者把DataGet做成static的