-1
我在asp.net中創建了一個簡單的休息服務mvc.my問題是我的值不傳遞給respository
類。我想我想念任何人都可以幫助..? 這裏是我的controller
未將值傳遞給存儲庫類
static LoginRespository repository = new LoginRespository();
public string AddEmployees(Login Emp)
{
//calling EmpRepository Class Method and storing Repsonse
var response = repository.AddEmployees(Emp);
return response;
}
和我respository
類這樣
public string AddEmployees(Login Emp)
{
SqlCommand com;
SqlConnection con = new SqlConnection(@"Data Source=DOTNET;Initial Catalog=edin;Integrated Security=True;Pooling=False");
try
{
com = new SqlCommand("select * from data where name='" + Emp.username + "'", con);
con.Open();
SqlDataReader dr = com.ExecuteReader();
if (dr.HasRows)
{
return "success";
}
else
{
return "error";
}
con.Close();
}
catch (Exception aa)
{
return aa.ToString();
}
}
和我model
是
public string username { get; set; }
public string password { get; set; }
你怎麼用你的控制器?你能證明你如何將價值傳遞給控制器嗎? – bogzy
'var response = repository.AddEmployees(Emp);'//調用EmpRepository類方法並存儲Repsonse – Edison
對不起,我的意思是。你如何在客戶端調用控制器?你確定(Emp)有價值嗎? – bogzy