G
Guest
Hi,
I have the foll code in a class.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Security.Principal;
namespace SpxConnectionStrings
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class dbConnection
{
public SqlConnection Get()
{
//
// TODO: Add constructor logic here
//
if (false)
{
return null;
}
WindowsIdentity CallersIdentity = windowsIdentity.GetCurrent();
If (CallersIdentity.IsAuthenticated == false);
{
return null;
}
string myConnectionString = "Initial Catalog=Northwind;Data
Source=xx.xx.xx.xx;Integrated Security=SSPI;";
SqlConnection myConnection = new
SqlConnection(myConnectionString);
return myConnection;
}
}
}
I get the following error when I compile the project
D:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(21):
Unreachable code detected
x:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(24): The
type or namespace name 'windowsIdentity' could not be found (are you missing
a using directive or an assembly reference?)
x:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(26): The
name 'If' does not exist in the class or namespace
'SpxConnectionStrings.dbConnection'
x:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(37):
Unreachable code detected
Any ideas?
Thanks
I have the foll code in a class.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Security.Principal;
namespace SpxConnectionStrings
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class dbConnection
{
public SqlConnection Get()
{
//
// TODO: Add constructor logic here
//
if (false)
{
return null;
}
WindowsIdentity CallersIdentity = windowsIdentity.GetCurrent();
If (CallersIdentity.IsAuthenticated == false);
{
return null;
}
string myConnectionString = "Initial Catalog=Northwind;Data
Source=xx.xx.xx.xx;Integrated Security=SSPI;";
SqlConnection myConnection = new
SqlConnection(myConnectionString);
return myConnection;
}
}
}
I get the following error when I compile the project
D:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(21):
Unreachable code detected
x:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(24): The
type or namespace name 'windowsIdentity' could not be found (are you missing
a using directive or an assembly reference?)
x:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(26): The
name 'If' does not exist in the class or namespace
'SpxConnectionStrings.dbConnection'
x:\Projects\Programs\c#.net\SpxConnectionStrings\dbConnection.cs(37):
Unreachable code detected
Any ideas?
Thanks