Solved

public bool in model

Posted on 2012-12-21
2
334 Views
Last Modified: 2012-12-21
public bool Passwordchange(string _Username, string _Password)
{
	using (cn == new SqlConnection("")) {
		string _sql = "sp";
		if (_Password != "") {
			DecryptText obj = new DecryptText();
			_Password = obj.QueryStringEncode(_Password.Trim);
		}
		object cmd = new SqlCommand(_sql, cn);
		cmd.CommandType = CommandType.StoredProcedure;
		cmd.Parameters.Add(new SqlParameter("@username", SqlDbType.VarChar)).Value = _Username;
		cmd.Parameters.Add(new SqlParameter("@NewPassword", SqlDbType.VarChar, 15)).Value = _Password;
		try {
			cn.Open();
			cmd.ExecuteNonQuery();
			return true;
		} catch (Exception ex) {
			return false;
		} finally {
			cn.Close();
			cmd.Dispose();
		}

	}
}

Open in new window


Public bool keep getting error to use enum, class ect.
0
Comment
Question by:sevensnake77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 38714380
Try adding static.   A module can't have any instance functions . . . only static/shared (c# / vb.net) functions.

public static bool Passwordchange(string _Username, string _Password)

and FYI I would use a variable otherwise your connection isn't closed/disposed.

eg:

bool result;

result = true;

catch
{
 result = false;
  // other code
}

finally
{

   conn.Close();
   conn.dispose();
   return result;
}
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 38714388
tks
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question