如何在VB.NET表单中存储SQL服务器中的视频和图像 [英] How to store video and images in SQL server from VB.NET form

查看:73
本文介绍了如何在VB.NET表单中存储SQL服务器中的视频和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个我已经放置的表单



QID

问题

选择1

选择2

选择3

选择4

选择5

CorrectAns



我想在Sql Server中存储这些东西。问题可以是文字,图像,视频。



当我通过QID搜索问题时,每个与QID相关的内容都应该显示在相应的字段中。



怎么办?



我的尝试:



简单来说,当问题字段是文本时,在带有sql server的vb.net中插入更新删除查询是可能的。但是如何处理图像和视频

I am creating a form in which I have put

QID
Question
Choice 1
Choice 2
Choice 3
Choice 4
Choice 5
CorrectAns

These things I want to store in Sql Server. the question can be Text, Image, Video.

When I search question by QID every thing relating to the QID should be shown in respective field.

How to do?

What I have tried:

In a simple way inserting updating deleting querying is possible in vb.net with sql server when question field is text. but how to do with image and video also

推荐答案

你可以通过将所有内容以二进制格式存储在所谓的LOB中来实现: LOB和二进制数据有什么区别在SQL Server中? - 数据库管理员堆栈交换 [ ^ ] - 基本上,使用VARBINARY(MAX)你应该没问题。



但是......这是一个坏主意。特别是视频变得非常大,非常快,并且将其存储在SQL中意味着它将使用大量的SQL带宽来存储和访问 - 两个或更多用户同时执行此操作会导致SQL开始停止运行!



相反,将其存储在一个文件中,并在SQL中存储该文件的路径(加上原始文件名)(我使用GUID作为文件名)这样多个用户可以拥有相同的文件名和不同的内容)。如果用户可以访问这些文件,那么它可以解决相同的问题,但会减少SQL的负担并使整个数据库更容易备份!
You can do it, by storing it all in a binary format, in what is called a LOB: What is the difference between LOB and binary data in SQL Server? - Database Administrators Stack Exchange[^] - basically, use VARBINARY(MAX) and you should be fine.

But ... it's a bad idea. Video in particular becomes very large,m very quickly, and storing it in SQL means it will use huge amounts of SQL bandwidth to store and access - two or more users doing this at the same time can cause SQL to start to grind to a halt!

Instead, store it in a file, and store the path to that file (plus the original file name) in SQL (I use a GUID as the file name so that multiple users can have the same file name with different content). Provided the files are accessible to the user it works out the same, but reduces the load on SQL and makes the DB a whole load easier to back up!


这篇关于如何在VB.NET表单中存储SQL服务器中的视频和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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