C
C#8mo 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
TheBoxyBear8mo 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
lucaOP8mo ago
Yes, it is a database What kind of link?
Jimmacle
Jimmacle8mo 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
MODiX8mo 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
Jimmacle8mo 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
lucaOP8mo 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
Jimmacle8mo ago
you probably can unless your concern is data loss
luca
lucaOP8mo ago
it's an sql server database
Jimmacle
Jimmacle8mo ago
just drop the column and re-add it with a different type
luca
lucaOP8mo ago
can you help me on that?
Jimmacle
Jimmacle8mo ago
it's pretty easy to look up, but i can help if you get stuck
luca
lucaOP8mo 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
Jimmacle8mo 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
lucaOP8mo ago
Oh I understand, i thought that all the data will be lost my bad here thank you
Jimmacle
Jimmacle8mo ago
only the data in the specific thing you're dropping, in this case the logo column
luca
lucaOP8mo ago
yes, it worked really well thank you so much! actually, now I got this error for the FIll method
luca
lucaOP8mo ago
No description
Alen Alex
Alen Alex8mo 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 User8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server