如何将图像保存和检索到SQL Server数据库的文本(数据类型)列。 [英] How can I can save and retrieve image to SQL server database's text(data type) column.

查看:74
本文介绍了如何将图像保存和检索到SQL Server数据库的文本(数据类型)列。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一个有3列的桌子:

名字字符(50)

位置字符(50)

图片(文字)



如何以文本数据类型保存图像?转换将如何?感谢您的帮助。使用C#,SQL-Server,Windows表单应用程序



我尝试过:



这是我第一次听到图像可以保存为文本数据类型,所以我不知道该尝试什么。抱歉。

Hello. I have a table with 3 columns:
Name Char(50)
Location Char(50)
Image(text)

How can I save an image in a text datatype? how's the conversion will be? Thanks for your help in advance. Using C#, SQL-Server, Windows Form Application

What I have tried:

It's my first time to hear that images can be saved in a text data type so I have no idea what to try yet. Sorry.

推荐答案

在SQL Server中存储或保存图像 [ ^ ]

使用标记过程和C#从SQL Server存储和检索图像 [ ^ ]



如果你扩展你的搜索超越了CP,你会发现成千上万的答案...
Store or Save images in SQL Server[^]
Storing and Retrieving Images from SQL Server Using Strored Procedures and C#[^]

And if you extend your search beyond CP, you will find thousands of answers...


不要将图像存储在文本列中,你必须将图像转换为类似Base64的东西以避免出现问题 - 而且就空间而言,效率非常低。

而是使用VARBINARY colu mn,并通过参数化查询直接插入图像中的字节。

这显示了代码:为什么我得到参数无效。我从数据库中读取图像时出现异常? [ ^ ]
Don't store images in text columns, you have to convert the image to something like Base64 to avoid problems - and that gets very inefficient as far as space is concerned.
Instead use a VARBINARY column, and insert the bytes from the image directly via a parameterised query.
This shows the code to do it: Why do I get a "Parameter is not valid." exception when I read an image from my database?[^]


这篇关于如何将图像保存和检索到SQL Server数据库的文本(数据类型)列。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆