Click here to Skip to main content
15,921,028 members
Home / Discussions / C#
   

C#

 
AnswerRe: .NET Serialization question Pin
Mark Churchill28-Jan-09 12:02
Mark Churchill28-Jan-09 12:02 
GeneralRe: .NET Serialization question Pin
Ennis Ray Lynch, Jr.28-Jan-09 12:37
Ennis Ray Lynch, Jr.28-Jan-09 12:37 
GeneralRe: .NET Serialization question Pin
Mark Churchill28-Jan-09 13:34
Mark Churchill28-Jan-09 13:34 
GeneralRe: .NET Serialization question Pin
Ennis Ray Lynch, Jr.28-Jan-09 15:27
Ennis Ray Lynch, Jr.28-Jan-09 15:27 
GeneralRe: .NET Serialization question Pin
Mark Churchill28-Jan-09 16:06
Mark Churchill28-Jan-09 16:06 
GeneralRe: .NET Serialization question Pin
Ennis Ray Lynch, Jr.29-Jan-09 2:35
Ennis Ray Lynch, Jr.29-Jan-09 2:35 
QuestionHow to Change DataGridBoolColumn's greyed state and checked to DataGridBoolColumn's greyed state and unchecked ? Pin
JuergenLissmann28-Jan-09 3:49
JuergenLissmann28-Jan-09 3:49 
Question[newbie] function to return MAX + 1 from primary key Pin
jon-8028-Jan-09 3:38
professionaljon-8028-Jan-09 3:38 
I'm creating a function that should return the max value of a field within the database..

1. Any idea why I'm getting the following compilation errors?

2. I need to return a value of type System.Data.Sqltypes.SqlInt64, whilst the return value is a string, any idea how to do the conversion? An explicit cast does not work i.e.

if (rawValue != DBNull.Value) {
                    return {System.SqlTypes.SqlInt64.rawValue.ToString();


Errors:
1. Warning 1 Unreachable code detected C:\Inetpub\wwwroot\TaskEntry\TaskEntry.aspx.cs 163 13 C:\...\TaskEntry\
2. Error 2 'TaskEntry.nextTaskRef()': not all code paths return a value C:\Inetpub\wwwroot\TaskEntry\TaskEntry.aspx.cs 149 43 C:\...\TaskEntry\



private System.Data.SqlTypes.SqlInt64 nextTaskRef() { 
    
        try
        {
                string getTaskRef = @"SELECT MAX([taskID_PK]) FROM [teamwiki].[dbo].[task];";
                SqlCommand getTaskRefSQL = new SqlCommand(getTaskRef, conAppDB);

                object rawValue = getTaskRefSQL.ExecuteScalar();
                if (rawValue != DBNull.Value) {
                    return (System.Data.SqlTypes.SqlInt64) rawValue;

                }
        }
        catch (Exception ex) {
            throw ex;
            return 0; //tried to return null as well unsuccessfullly
                      //this indicates an error condition :)
        }
        finally {
            conAppDB.Close();
        }
    }


Environment notes

Visual Studio 2005 Team edition / .NET 2.0
ASP.NET
SQL Server 2005
Win XP SP3

Jon

modified on Wednesday, January 28, 2009 10:00 AM

AnswerRe: [newbie] function Pin
SeMartens28-Jan-09 3:45
SeMartens28-Jan-09 3:45 
AnswerRe: [newbie] function Pin
Karmendra Suthar28-Jan-09 3:54
Karmendra Suthar28-Jan-09 3:54 
GeneralRe: [newbie] function Pin
jon-8028-Jan-09 5:59
professionaljon-8028-Jan-09 5:59 
AnswerRe: [newbie] function to return MAX + 1 from primary key Pin
Wendelius28-Jan-09 4:33
mentorWendelius28-Jan-09 4:33 
AnswerRe: [newbie] function to return MAX + 1 from primary key Pin
riced28-Jan-09 5:10
riced28-Jan-09 5:10 
QuestionRatio Textbox Validation Pin
honeyashu28-Jan-09 3:37
honeyashu28-Jan-09 3:37 
AnswerRe: Ratio Textbox Validation [modified] Pin
DaveyM6928-Jan-09 3:56
professionalDaveyM6928-Jan-09 3:56 
GeneralRe: Ratio Textbox Validation Pin
honeyashu28-Jan-09 20:31
honeyashu28-Jan-09 20:31 
GeneralRe: Ratio Textbox Validation Pin
DaveyM6929-Jan-09 0:11
professionalDaveyM6929-Jan-09 0:11 
QuestionJPEG Compression in C# Pin
SimpleData28-Jan-09 3:26
SimpleData28-Jan-09 3:26 
AnswerRe: JPEG Compression in C# Pin
User 665828-Jan-09 3:30
User 665828-Jan-09 3:30 
AnswerRe: JPEG Compression in C# Pin
SimpleData28-Jan-09 3:39
SimpleData28-Jan-09 3:39 
AnswerRe: JPEG Compression in C# Pin
Ennis Ray Lynch, Jr.28-Jan-09 5:26
Ennis Ray Lynch, Jr.28-Jan-09 5:26 
GeneralRe: JPEG Compression in C# Pin
SimpleData28-Jan-09 5:29
SimpleData28-Jan-09 5:29 
GeneralRe: JPEG Compression in C# Pin
Ennis Ray Lynch, Jr.28-Jan-09 5:42
Ennis Ray Lynch, Jr.28-Jan-09 5:42 
GeneralRe: JPEG Compression in C# Pin
SimpleData28-Jan-09 6:02
SimpleData28-Jan-09 6:02 
GeneralRe: JPEG Compression in C# Pin
Mark Churchill28-Jan-09 12:11
Mark Churchill28-Jan-09 12:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.