[WebMethod]
public static string CreateProfileID(string firstName, string lastName)
{
string profileID = "";
using (SqlConnection conn = Common.getConnection())
{
try
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = string.Format("select dbo.[create-something] ('{0}', '{1}') as somethingID", firstName, lastName);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
profileID = dr["somethingID"] as string;
}
}
catch (Exception e)
{
}
}
return profileID;
}
public static string CreateProfileID(string firstName, string lastName)
{
string profileID = "";
using (SqlConnection conn = Common.getConnection())
{
try
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = string.Format("select dbo.[create-something] ('{0}', '{1}') as somethingID", firstName, lastName);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
profileID = dr["somethingID"] as string;
}
}
catch (Exception e)
{
}
}
return profileID;
}
Everything in one method: How to handle exceptions.
!!!FAIL!!!
No comments:
Post a Comment