C
C#11mo ago
luca

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?
No description
No description
19 Replies
TheBoxyBear
TheBoxyBear11mo ago
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.
luca
lucaOP11mo ago
Yes, it is a database What kind of link?
Jimmacle
Jimmacle11mo ago
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
MODiX
MODiX11mo ago
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)
Jimmacle
Jimmacle11mo ago
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-ver16
luca
lucaOP11mo ago
yes, i just realized that's the best method but the datatype is already set and from what I know I can't change it
Jimmacle
Jimmacle11mo ago
you probably can unless your concern is data loss
luca
lucaOP11mo ago
it's an sql server database
Jimmacle
Jimmacle11mo ago
just drop the column and re-add it with a different type
luca
lucaOP11mo ago
can you help me on that?
Jimmacle
Jimmacle11mo ago
it's pretty easy to look up, but i can help if you get stuck
luca
lucaOP11mo ago
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?
Jimmacle
Jimmacle11mo ago
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 first
luca
lucaOP11mo ago
Oh I understand, i thought that all the data will be lost my bad here thank you
Jimmacle
Jimmacle11mo ago
only the data in the specific thing you're dropping, in this case the logo column
luca
lucaOP11mo ago
yes, it worked really well thank you so much! actually, now I got this error for the FIll method
luca
lucaOP11mo ago
No description
Alen Alex
Alen Alex11mo ago
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
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?