public string CustomerName(int custId)
{
SqlCommand cmd = new SqlCommand(string.Format(“SELECT Name FROM Customers WHERE idCust = {0}”, custId), sqlConnectionToSchaakBondDB);
object result = cmd.ExecuteScalar();
if (result == null)
return “Customer not found”;
if (result == System.DBNull.Value)
return “Customer found but name is null”;
return (string) result;
}
{
SqlCommand cmd = new SqlCommand(string.Format(“SELECT Name FROM Customers WHERE idCust = {0}”, custId), sqlConnectionToSchaakBondDB);
object result = cmd.ExecuteScalar();
if (result == null)
return “Customer not found”;
if (result == System.DBNull.Value)
return “Customer found but name is null”;
return (string) result;
}
No comments:
Post a Comment