I have a database with image URL's. I have a stored procedure hat GET's the url's (SP_GET_Image) I want execute the stored proc then for each of the URL's get the image.
I want the actual image locally not the url.
Then for each image I want to save them locally. I have this code but want to know how do I save each image in a datarow.
I have started with the code.
Dim CMD as new sqlCommand("StoredProcedureName")
CMD.parameters("@Parameter1", sqlDBType.Int).value = Param_1_value
Dim connection As New SqlConnection(connectionString)
CMD.Connection = connection
CMD.CommandType = CommandType.StoredProcedure
Dim adapter As New SqlDataAdapter(CMD)
adapter.SelectCommand.CommandTimeout = 300
'Fill the dataset'
Dim DS as DataSet
adapter.Fill(ds)
connection.Close()
'Now, read through your data:'
For Each DR as DataRow in DS.Tables(0).rows
'<-- Im not sure here how to GET EACH images locally saved.
Next
c# or vb help is fine.
The url looks like this :
http://img.myCompany.net/p/1483/278227_20094171232290.jpg
You can use My.Computer.Network.DownloadFile in order to download and store the file on local machine or a remote server supplying a user name and password (if required). As you need to specify the file name when downloading, you can extract it from the URL with SubString(URL.LastIndexOf("/") + 1)
For Each DR as DataRow in DS.Tables(0).Rows
Dim URL as String = DR("Your_URL_Column_Name").ToString()
Dim Destination as String = "\\SERVERNAME\FolderName\"
My.Computer.Network.DownloadFile(URL, Destination & SubString(URL.LastIndexOf("/") + 1), "name", "password")
Next
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With