Solved

public bool in model

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

10 Experts available now in Live!

Get 1:1 Help Now