The SqlDataSource is intended as what the name implies - a data source for data binding. It is not a way to get individual values from a database table.
If you need to read a single value, you should use straight ADO.NET - SqlConnection and SqlCommand - to read that value - something like:
string sqlStmt = "SELECT FirstName FROM dbo.YourTable WHERE ID = @ID";
using(SqlConnection conn = new SqlConnection(your-connection-string-here-))
using(SqlCommand cmd = new SqlCommand(sqlStmt, conn))
{
cmd.Parameters.Add("@ID", SqlDbType.Int).Value = 4044;
conn.Open();
string firstName = cmd.ExecuteScalar().ToString();
conn.Close();
}
The ExecuteScalar call works only if you want to read a single row, single column value - like here. Otherwise you need to use either the SqlDataReader, or use the DataTable and a SqlDataAdapter to fill that data table (if you have multiple rows).
Update: if you want to use a SqlDataAdapter instead - do this:
public DataTable LoadData()
{
DataTable result = new DataTable();
string sqlStmt = "SELECT ID, FirstName, LastName, Country " +
"FROM dbo.YourTable";
using(SqlConnection conn = new SqlConnection(your-connection-string-here-))
using(SqlCommand cmd = new SqlCommand(sqlStmt, conn))
{
SqlDataAdapter dap = new SqlDataAdapter(cmd);
dap.Fill(result);
}
return result;
}
When you call this method, you'll get back a DataTable that contains the columns you've defined in your SQL statement, and all rows from the database table.
DataTable myData = LoadData();
Now, you can iterate over the rows and get the FirstName value for each row:
foreach(DataRow row in myData.Rows)
{
string firstName = row["FirstName"].ToString();
// do whatever you need to do with the first name
}