如何在VB中从SQL服务器检索文件? [英] How do I retrieve file from SQL server in VB?

查看:89
本文介绍了如何在VB中从SQL服务器检索文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在datagridview中检索word文档而不是图像。请帮我!!



我的数据库名称是testattach,我的表名是FileWarehouse。在我的表中,有id,filetype和storedfile。存储的文件在word doc中。



当我尝试运行此代码时,它会显示除存储文件以外的所有内容,但我无法打开它。请尽快帮助我



我的尝试:



I want to retrieve word document and not image in a datagridview. Please help me!!

My database name is testattach and my table name is FileWarehouse. In my table, there are id, filetype and the storedfile. the stored file is in word doc.

When I try to run this code, it displays everything except for the stored file and I cannot open it. Please Help me ASAP

What I have tried:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim str As String = "Server = HRCS-SGH447S14G\COMPASS; Database = testattach; Integrated Security = true"
        Dim con As New SqlConnection(str)
        Dim com As String = "Select * from FileWarehouse "
        Dim Adpt As New SqlDataAdapter(com, con)
        Dim ds As New DataSet()
        Adpt.Fill(ds, "FileWarehouse")
   
        DataGridView1.DataSource = ds.Tables(0)
    End Sub

推荐答案

您不仅可以将Word数据抛出到DataGridView中,而且希望它知道如何显示它 - 它可以理解大多数格式的图像,但这很重要。它不懂Word文件(多年来使用的各种文件格式),它不懂Excel文件,它不懂PDF文件,它不懂HTML文件。差不多,它不是文本或图像格式,它不理解它。

你不能只是在DGV上转储一个word文件并期望它显示文件内容。



即使你可以,你确实知道word文档的大小至少是A4,通常是多页?您如何看待在DGV中显示它作为用户体验?
You can't just "throw" Word data into a DataGridView and expect it to know how to display it - it understands images in most formats, but that is about it's lot. It doesn't understand Word files (any of the various file formats that have been used over the years), it doesn't understand Excel files, it doesn't understand PDF files, it doesn't understand HTML files. Pretty much, it it isn't text or an image format, it doesn't understand it.
You cannot just dump a word file on a DGV and expect it to display the file content.

And even if you could, you do realize that word documents tend to be at least A4 in size, and generally multipage? How do you think displaying that in a DGV is going to work as a user experience?


这篇关于如何在VB中从SQL服务器检索文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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