?
Solved

public bool in model

Posted on 2012-12-21
2
Medium Priority
?
336 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:Seven price
[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 2000 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:Seven price
ID: 38714388
tks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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