Help with image datatype
Hello. I created a table with a column whose data type is image, but I don't know how to add them to the table. Any ideas?
19 Replies
What kind of table? If it's a database, the actual field needs to be some link to the image and not the image binary itself.
Yes, it is a database
What kind of link?
if you're trying to put binary blobs in your database then exactly how you do that depends on the db and library you're using
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, what you expect the result to be, what .NET version you are using and what platform/environment (if any) are relevant to your question. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
generally you do what @TheBoxyBear said and just store files in the filesystem and only store their path in the DB
or some databases like MS SQL have actual
FILESTREAM
types you can use
https://learn.microsoft.com/en-us/sql/relational-databases/blob/filestream-sql-server?view=sql-server-ver16yes, i just realized that's the best method
but the datatype is already set and from what I know I can't change it
you probably can unless your concern is data loss
it's an sql server database
just drop the column and re-add it with a different type
can you help me on that?
it's pretty easy to look up, but i can help if you get stuck
Alright
I'll try my best
One question, if I drop the column will the other tables that have a relation with this one also lose data?
i doubt you have any relationships defined on an
image
column, but if you do it will fail to drop the column
if in doubt make a backup firstOh I understand, i thought that all the data will be lost
my bad here
thank you
only the data in the specific thing you're dropping, in this case the
logo
columnyes, it worked really well thank you so much!
actually, now I got this error for the FIll method
As the error message says, you are trying to insert an array of bytes (DataColumn), but what actually needed there is a string (URL of some kind pointing to that image)
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View