Solved

public bool in model

Posted on 2012-12-21
2
329 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now