I have stored an image in SQL Server. First I have converted the image into bytes and I have saved it in SQL Server and very much done with saving.....when I try to invoke the respective image's bytes value from SQL Server which I saved and when I try to implement that in C#, I am getting a error like
NullReferenceException was unhandled by user code
Object Reference not set to an instance of an object
Here is my code:
protected void GetImageButton_OnClick(object sender, EventArgs e)  
{  
    SqlConnection connection = new SqlConnection();  
    connection.ConnectionString = @"";  
    connection.Open();  
    SqlCommand command = new SqlCommand();  
    command.Connection = connection;  
    command.CommandType = CommandType.StoredProcedure;  
    command.CommandText = "uspgetimage";  
    command.Parameters.AddWithValue("@imageID", getimagebutton.Text);  
    DataSet dataset = new DataSet();  
    SqlDataAdapter adapter = new SqlDataAdapter();  
    adapter.SelectCommand = command;  
    adapter.Fill(dataset);  
    Byte[] bytes = command.ExecuteScalar() as byte[];  
    string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);  
    Image.ImageUrl = "data:image/jpeg;base64," + base64String;  
}  
Kindly have a look on it and help me to get out from this friends.
 
     
     
     
    