Depending on the size of the data, use an image datatype in your tables, and read the data from the WebBrowser control.DocumentText - this gives you the HTML for the page as a string.
Then just convert it to bytes:
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(s);
and insert it to your database.
using(SqlCommand com = new SqlCommand("INSERT INTO myTable (scrapedData) VALUES (@SD)", con))
{
com.Parameters.AddWithValue("@SD", bytes);
s.ExecuteNonQuery();
}
[edit]Passed string "s" to parameters instead of byte[] "bytes" - OriginalGriff[/edit]
"Yeah i know but how do I read it onto the web browser control?"
Response.ContentType = "image/JPEG";
Response.BinaryWrite(myBytesFromDataBase);
"It still isnt working, its not recognizing the response or the BinaryWrite. I've put my code in the question so you can take a look."
Perhaps, if somewhere between reading the data from the database and writing it into the response, you actually used the info from the database, it might work better as an image than the HTML does...
private void btnRead_Click(object sender, EventArgs e)
{
string html = this.GetWebsiteHtml(this.txtUrl.Text);
this.wbHtmlpage.DocumentText = html;
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(html);
...
da.SelectCommand = new SqlCommand("Select WebsiteImage From Website Where WebsiteID = 3", cs);
da.Fill(ds, "Website");
--->>> Perhaps a bit of code to use your database info here, might help a bit!
response.ContentType = "Image";
response.BinaryWrite(bytes);
cs.Open();
cs.Close();
}
I would also suggest that your connection "cs" might be more usefully opened before you try to read from it, rather than after... :laugh: