473,408 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Dot net error discussion

Hello

I am writing the following code

public bool validation(string uname, string pword)
{
uname = username;
pword = password;

dbinsert db = new dbinsert();
SqlDataReader dr = db.Datareader("select Password from registration where UserName='" + uname.ToString() + "'");


if (dr.Read())
{

if (pword == dr["Password"].ToString())
{
return (true);
}
else
{
return (false);
}
}

The above error is showing the following error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0161: 'LoginCtrl.validation(string, string)': not all code paths return a value

Source Error:



Line 51: }
Line 52:
Line 53: public bool validation(string uname, string pword)
Line 54: {
Line 55: uname = username;


Source File: d:\AJAXEnabledWebSite1\LoginCtrl.ascx.cs Line: 53



Pleaes solve the problem as soon as possible
May 10 '07 #1
3 979
give another "return" true/false outside the if/else statement.

-Jati Indrayanto
May 10 '07 #2
Paulson
63
give another "return" true/false outside the if/else statement.

-Jati Indrayanto
Hi RajNandi


I have been working in vb and urs is c#,but still i think if you just dclare
a variable for exampl result as boolean and set its value instead of returning true false directly I think it shud work. ie
your

code part

__________________________________________________ _______________

if (dr.Read())
{

if (pword == dr["Password"].ToString())
{
return (true);
}
else
{
return (false);
}
}

__________________________________________________ _______________

must be as follows ----->

__________________________________________________ _______________

if (dr.Read())
{

if (pword == dr["Password"].ToString())
{
result =true;
}
else
{
result =false;
}
return;
}

__________________________________________________ _______________


Try this and check if it works if it works pls inform,sorry if I could not help you

Anyway keep the good work going.



bye Paulson.
May 10 '07 #3
TRScheel
638 Expert 512MB
Hello

I am writing the following code

public bool validation(string uname, string pword)
{
uname = username;
pword = password;

dbinsert db = new dbinsert();
SqlDataReader dr = db.Datareader("select Password from registration where UserName='" + uname.ToString() + "'");
....

DO NOT DO THAT...

You will regret it if someone decides to do sql injections on you.

Imagine if someone put their username as

a' or 'a'='a

Stored procedures, or even just checking the username/password strings for sql injections will save you, but for the love of whomever you choose, dont use programmatic strings.
May 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
4
by: Peter Olcott | last post by:
Yesterday I found that an invocation of a member function that lacked the required "()" pararenthesis did not generate an error message. This was an invocation of a member function that is part of...
3
by: Hugh O | last post by:
Hi, I have been trying to load a Crystal Report newly created via VS.Net 2003. I am using a simply ASP form with only the Crystal Report Viewer. The sample report results display in the...
0
by: Harry Smith | last post by:
This was posted in news.groups, but it was not posted to the list. REQUEST FOR DISCUSSION (RFD) unmoderated group comp.databases.postgresql.admin unmoderated group...
33
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: deane.barker | last post by:
Is there any recommended solution to this error message? I get it *all the time.* It's seemingly random, but it obviously happens right after I change some code so a page or the app recompiles....
5
by: Tyler | last post by:
Hello All: Since my last post I have attempted to use the f2py program which comes with numpy. I am able to create a <module_name>.so file fine; however, when I import it into Python, I receive...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
17
by: =?Utf-8?B?SGVyYg==?= | last post by:
I have created a report and subreport in VB/ASP.NET. The report works fine but the subreport will not display. The subreport, when displayed as a standalone report, works fine. Any help I can...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.