Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ExecuteScalar() question
Message
De
25/08/2003 14:14:54
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
ExecuteScalar() question
Divers
Thread ID:
00823142
Message ID:
00823142
Vues:
53
Hi all,

Can I optimze these lines of code to a single line of code? These codes executes ExecuteScalar() twice if there is a result. Assume there is no error.
OracleConnection con = new OracleConnection(
	ConfigurationSettings.AppSettings["cnQuo.ConnectionString"]);
OracleCommand cmd = new OracleCommand(
	"SELECT CompanyID FROM Quo.Company " +
	"WHERE CompanyName = '" + txtCompanyName.Text.Trim() + "'", con);
string companyID;
con.Open();
if (cmd.ExecuteScalar() == null) {companyID = string.Empty;}
else {companyID = cmd.ExecuteScalar().ToString();}
ramil
~~ learning to stand still
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform