要存储和检索excel/doc/pdf文件或其他exe到sql2000数据库中 [英] To store & retrieve the excel/doc/pdf files Or others exe into sql2000 database

查看:118
本文介绍了要存储和检索excel/doc/pdf文件或其他exe到sql2000数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel文件/位置中存在其他应用程序exe文件.
我想将文件从SQL2000数据库存储/检索到SQL2000数据库中,而不是图像.

我将如何解决以上问题????
为方便起见,请帮助我进行任何说明.......

I have a excel file/Other application exe file are existing in location.
I want to store/retrive that files from/into SQL2000 Database, but not image.

How will i do above problem??????
Please help me any instruction for my convenience.......

推荐答案

代码与位图的代码相同,在每种情况下,盲目保存二进制格式,SQL Server不知道您的excel文档或位图是什么,它只是逐字保存为字节流.
The code is the same as the code for a bitmap, in each case, you''re blindly saving a binary format, SQL Server has no idea what your excel document or bitmap is, it just saves it verbatim as a stream of bytes.


此代码可用于从Excel导入数据到SQL数据库.

其中Test.Xlsx是Excel工作表,而Excel是数据库表

this Code for Import data from Excel to SQL DataBase.

Where Test.Xlsx Is excel sheet and Excel is DataBase Table

Imports System.Data.SqlClient
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

         Dim MyConnection As System.Data.OleDb.OleDbConnection
        Dim DtSet As System.Data.DataSet
        Dim MyCommand As System.Data.OleDb.OleDbDataAdapter

        Dim fBrowse As New OpenFileDialog
        With fBrowse
            .Filter = "Excel files(*.xlsx)|*.xlsx|All files (*.*)|*.*"
            .FilterIndex = 1
            .Title = "Import data from Excel file"
        End With
        If fBrowse.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Dim fname As String
            fname = fBrowse.FileName
            MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source='" & fname & " '; " & "Extended Properties=Excel 8.0;")
            MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1


",MyConnection中选择*) MyCommand.TableMappings.Add(" " 测试") DtSet = 新建 System.Data.DataSet MyCommand.Fill(DtSet) MyConnection.Close() 对于 每个 Drr As DataRow 在DtSet.Tables中( 0 ). Execute_Local(" & Drr( 0 ).ToString& " & Drr( 1 ).ToString& " ','"& Drr(" ')") 下一步 MsgBox(" ) 结束 如果 结束 结束
", MyConnection) MyCommand.TableMappings.Add("Table", "Test") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) MyConnection.Close() For Each Drr As DataRow In DtSet.Tables(0).Rows Execute_Local("INSERT INTO Excel(Name, Designation, Salary) VALUES ('" & Drr(0).ToString & "','" & Drr(1).ToString & "','" & Drr(2).ToString & "')") Next MsgBox("Successfully Saved") End If End Sub End Class


这篇关于要存储和检索excel/doc/pdf文件或其他exe到sql2000数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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