Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i create login_class in that class i code this

C#
public void loginfu(string username,string password)
   {
       try
           {
              Entities2 lg = new Entities2();

              List<SP_Get> gr = lg.SP_GetL(username, password).ToList();
               DataTable dt = new DataTable();
               dt.Columns.Add("id", typeof(string));
               foreach (var l in gr)
               {
                   dt.Rows.Add(l.id);
               }

           }
          catch (Exception)
           {
               throw new Exception();

           }
           return dt;
   }


What I have tried:

how i pass column id in session
Posted
Updated 30-Aug-16 23:44pm
v7
Comments
Bernhard Hiller 31-Aug-16 3:26am    
Compile time or run-time error? Which line?
by the way, catch (Exception) {throw new Exception() is nonsense: you throw away all the information you could get from the original exception. Don't do that!
super_user 31-Aug-16 3:54am    
check update question
F-ES Sitecore 31-Aug-16 4:13am    
You need to stop what you're doing and get a book on c# and understand the basics of the language such as functions, tyres, classes etc before you can do anything more advance. Your code makes little sense and there are a few basic issues with how you are using the language. We could point out what these errors are but it wouldn't be helping you. If you want to code you need a better grasp of the basics.
super_user 31-Aug-16 5:45am    
you are right i need this :/ please suggest some good books

That's a fairly simple error to locate, if you have the code - which we don't.
It's a compiler error and it's coming because you have tried to do something like this:
C#
private void MyMethod() { ... }
...
var x = MyMethod().DoSomething();
Because MyMethod is defined as returning a void - i.e. no value - the compiler is complaining (correctly) that you can't use "." on a call to the method.

But we can't tell which line it complains about - so look at the error message, and it will tell you exactly which file and line within that file it found the problem with. Look at eth methods you call on that line, and it should be pretty obvious. Fixing it is up to you: why are you calling that method and expecting it to return a value at all?
 
Share this answer
 
Comments
super_user 31-Aug-16 3:54am    
check update question
You have defined loginfunction() to return bool not a DataTable hence the error on line :
C#
...
string logn = Convert.ToString(lg_class.loginfunction(UserName, Password).Tables[0].Rows[0]["id"]);
...
 
Share this answer
 
Comments
super_user 31-Aug-16 3:51am    
ok now i do that ..
private string loginmethod(string UserName, string Password)
{
login_class lg_class = new login_class();

try
{

Entities2 login = Entities2();


lg_class.loginfunction(UserName, Password);
Session["ID"]

return ;
}
catch (Exception ex)
{

throw new Exception();

}

Error 4 An object of a type convertible to 'string' is required
super_user 31-Aug-16 3:54am    
check update question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900