Out of range exception of a dataset
<p>Hoping this is a simple one</p>

<p>I am extracting the data from a column of my dataset. As the SQL query is supplied an ID only one result will ever be returned. So I would think this result would always be at row '0' of the dataset.</p>

<p>If i click the first result in my datagrid........send the id '0' across to my second page which then extracts the image name from the DB it crashes. If I select the second result in the grid i.e '1' it is fine.</p>

<p>Here is my code:</p>

<pre><code>     SqlConnection sqlcon = new SqlConnection(connstring);
        SqlCommand sqlcmd = new SqlCommand("select pic from cds WHERE _id = '" + passedID + "'", sqlcon);
        SqlDataAdapter adp = new SqlDataAdapter(sqlcmd);
        DataSet ds = new DataSet();
        adp.Fill(ds);
        // Rows set to '0' for the first result in the dataset but crashes if the first item is selected.
        object a = ds.Tables[0].Rows[0]["pic"];
        string test = a.ToString();
</code></pre>
