Click here to Skip to main content
15,885,957 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've the following code :-

C#
protected void BtnSave_Click(object sender, EventArgs e)
   {
       using (SampleDataContext dbContext = new SampleDataContext())
       {
           System.Nullable<char> outpt = null;
           long id = Convert.ToInt64(Session["USERID"]);
           dbContext.passwrdchange(id, old.Text.ToString().Trim(), newpass.Text.ToString().Trim(), ref outpt);

           if(outpt.ToString()=="T")
           {
               ClientScript.RegisterStartupScript(this.GetType(), "SuccessMsg", "<script>alert('Password Changed Successfully')</script>");
           }

           else
           {
               ClientScript.RegisterStartupScript(this.GetType(), "ErrorMsg", "<script>alert('Old Password Does Not Match with Records.')</script>");
           }
       }
   }


and in my Sample.designer.cs I've the code :-

C#
private void UpdateUser_Information(User_Information obj)
	{
		this.passwrdchange(((System.Nullable<long>)(obj.ID)), default(string), default(string),default(System.Nullable<char>));
	}


Now when I compile it gives the error :-

1.
C#
The best overloaded method match for 'SampleDataContext.passwrdchange(long?, string, string, ref char?)' has some invalid arguments


2.
C#
Argument 4 must be passed with the 'ref' keyword


Please Help. I don't understand what to do.
Posted
Comments
John C Rayan 31-Jan-16 2:50am    
you have to explain why you have the following code.

private void UpdateUser_Information(User_Information obj)
{
this.passwrdchange(((System.Nullable<long>)(obj.ID)), default(string), default(string),default(System.Nullable<char>));
}
Deepak Kanswal Sharma 31-Jan-16 7:07am    
It is a system generated code for linq.

1 solution

You expect
C#
Nullable<long>, string, string, ref Nullable<char></char></long>

But pass
C#
long, string, string, ref Nullable<char></char>

The problem is with the long - Nullable<long>...
 
Share this answer
 
Comments
Deepak Kanswal Sharma 31-Jan-16 7:15am    
I replaced it with this :-

System.Nullable<char> outpt = null;
System.Nullable<long> id = Convert.ToInt64(Session["USERID"]);
dbContext.passwrdchange(id, old.Text.ToString().Trim(), newpass.Text.ToString().Trim(), ref outpt);

Also I changed the line:-

this.passwrdchange(((System.Nullable<long>)(obj.ID)), default(string), default(string),default(System.Nullable<char>));

with

this.passwrdchange(((System.Nullable<long>)(obj.ID)), default(string), default(string),ref default(System.Nullable<char>));

The error changed to :-

"A ref or out argument must be an assignable variable"
Kornfeld Eliyahu Peter 31-Jan-16 7:18am    
And? The error message crystal clear...
Deepak Kanswal Sharma 31-Jan-16 8:35am    
I don't know what to assign to output parameter? We always send the null values to database right?

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