Why this function return value error?
I have a class in which I am returning a SqlConnection object the code has been
written in a try -catch block which is given below.
while I am trying to compile it is genrating this error
"Dal.cs(15): 'DataComponents.connectionClass.SetConnection()': not all code paths return a value"
Please help me. using
using
System.Data ;using
System;namespace
DataComponents{
///<summary>/// Summary description for Dal.///</summary>publicclass connectionClass{
staticstring connectionString="server=nic-dd;database=northwind;trusted_connection=true";static SqlConnection dbConnect;publicstatic SqlConnection SetConnection(){
try{
dbConnect=
new SqlConnection(connectionString );//throw new Exception () ;return dbConnect;}
catch(Exception Ex){
Console.WriteLine ("Error occured:{0}",Ex.Message );
}
finally{
dbConnect.Close();
}
}
}
}

