returning more than first element from sql server
From: cm_at_gowcity (cm_at_gowcity.fsnet.co.uk)
Date: 02/12/04
- Next message: Michael Pearson: "Re: returning more than first element from sql server"
- Previous message: Frasse: "Re: webservice problem: The underlying connection was closed: Unable to connect to the remote server"
- Next in thread: Michael Pearson: "Re: returning more than first element from sql server"
- Reply: Michael Pearson: "Re: returning more than first element from sql server"
- Reply: Tu-Thach: "RE: returning more than first element from sql server"
- Reply: Thomas Christiansen: "Re: returning more than first element from sql server"
- Messages sorted by: [ date ] [ thread ]
Date: 12 Feb 2004 12:36:55 -0800
IM AM NEW TO WEB SERVICE AND C# AND HAVE A QUESTION / PROBLEM
MY SIMPLE WEB METHOD
[WebMethod]
public string logtime(string ClientUserName)
{
try
{
SqlConnection sqlConn = new SqlConnection(
"data source=localhost;" +
"initial catalog=isa;integrated security=true");
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandText = "SELECT logTime FROM WebProxyLog " +
"WHERE ClientUserName = '" + ClientUserName + "'";
sqlCmd.Connection = sqlConn;
sqlConn.Open();
string logtime = (string)sqlCmd.ExecuteScalar();
sqlConn.Close();
return logtime;
}
catch(Exception e)
{
throw new Exception("Error calculating cost: " + e.Message);
}
}
NOW THIS RETURNS THE FIRST ELEMENT FROM THE SET RETURNED FROM THE
QUERY (ITHINK) BECAUSE I AM USING EXECUTESCALAR?
HOW COULD I MODIFY THIS TO RETURN ALL INSTANCES SO MY CLIENT
APPLICATION CAN ITERATE THROUGH EACH?
HOPE SOMEBODY HAS TIME FOR A NEWBIE
THANKS IN ADVANCE
COLIN
- Next message: Michael Pearson: "Re: returning more than first element from sql server"
- Previous message: Frasse: "Re: webservice problem: The underlying connection was closed: Unable to connect to the remote server"
- Next in thread: Michael Pearson: "Re: returning more than first element from sql server"
- Reply: Michael Pearson: "Re: returning more than first element from sql server"
- Reply: Tu-Thach: "RE: returning more than first element from sql server"
- Reply: Thomas Christiansen: "Re: returning more than first element from sql server"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|