Home Database Mysql Tutorial VFP将图片或其他文件保存到SQL Server的Text类型字段或者Access

VFP将图片或其他文件保存到SQL Server的Text类型字段或者Access

Jun 07, 2016 pm 03:43 PM
server sql keep picture document

*-- vfp8.0、9.0 *-- 保存 1、将 图片 文件 用 Filetostr ()转成字符A。 2、再用 Strconv (字符A,13)将字符A转成base64编码数据的字符B。 3、将字符B 保存 到SQL Server的Text 类型 字段 或者 Access的 备注 字段 。 *-- 还原 或 显示 1、用 Strconv (字符B,

*-- vfp8.0、9.0

*--保存
1、将图片文件Filetostr()转成字符A。
2、再用
Strconv("字符A",13)将字符A转成base64编码数据的字符B。
3、将字符B保存到SQL Server的Text类型字段或者Access的备注字段

*--还原显示
1、用 Strconv("字符B",14)将base64编码数据还原成未编码的数据字符A。
2、用
Strtofile()转成图片文件或把字符A覆给Image控件的PictureVal 属性来显示

*--图片例子
* 保存
lcTextString=Strconv(Filetostr("路径\图片名A"),13)&& base64编码数据,可以将此数据(lcTextString)保存

* 还原
=Strtofile(Strconv(lcTextString或表字段,14),"路径\图片名B")&& 将字符还原base64编码前数据,还原文件
Thisform.Image1.Picture="路径\图片名B"&& 将还原后的图片覆给Image控件的的Picture属性
* 或
Thisform.Image1.PictureVal=Strconv(lcTextString,14)&& 将字符还原base64编码前数据后直接覆给Image控件的PictureVal属性(VFP9.0)

*--注:
以上方法除了可以图片文件操作外,对其他文件如Word,文本,Exe,音频,视频等文件均可,但文件不要过大,否则速度慢。
*------------------
此方法也适用于DBF表的Memo字段(推荐用二进制备注字段,普通备注字段,在代码页有变化的时候会自动转变的,会破坏字段内容,二进制备注字段就不会。
如果直接用dbf二进制备注字段保存任何文件内容,那么可以直接用
Filetostr/Strtofile函数,不需要转成base64(SQL或Access需要转成base64),因为vfp没unicode功能,所有二进制文件功能都可用字符串函数来处理。)。
如果是DBF表的Memo字段,就直接用下面备注字段专用的命令,而且还可以保存还原文件(注:不管是什么数据库,不建议将大量大文件保存至表中),用
Filetostr/Strtofile函数对文件大小是有限制的。
* 保存
Append Memo Memo字段From 文件Overwrite

* 还原
Copy Memo Memo字段To 生成文件
*------------------
如果是VFP9.0建议改为使用
Blob 类型字段(对应SQL Server的Image或Text类型),它可以存储任何类型的数据。这样不需要使用 ActiveX,直接使用 vfp 自带的Image控件的PictureVal 属性即可显示 bmp/gif/png/jpg/tif 等格式的图片
Blob 类型字段要比上面方法好,因为前一种方法有一个缺点就是转成Base64后,数据变大了,不利于网络负载。
至于Blob类型字段文件存储和还原
*存储
Replace Blob字段With Filetostr("D:\文件全名")

*还原
=Strtofile(Blob字段,"d:\文件全名")

使用通用字段是已过时的技术,而且存在很多的弊病,例如:放入通用字段的图像没有绝对可靠的方法重新再保存为磁盘文件

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? Mar 22, 2024 am 08:06 AM

With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the "My" button in the lower right corner; (2) On the personal center page, find "Settings" and click it; (3) Scroll down and find the "Clear Cache" option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? Mar 21, 2024 pm 09:12 PM

With the popularity of Douyin short videos, user interactions in the comment area have become more colorful. Some users wish to share images in comments to better express their opinions or emotions. So, how to post pictures in TikTok comments? This article will answer this question in detail and provide you with some related tips and precautions. 1. How to post pictures in Douyin comments? 1. Open Douyin: First, you need to open Douyin APP and log in to your account. 2. Find the comment area: When browsing or posting a short video, find the place where you want to comment and click the "Comment" button. 3. Enter your comment content: Enter your comment content in the comment area. 4. Choose to send a picture: In the interface for entering comment content, you will see a "picture" button or a "+" button, click

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

How to save pictures without watermark in Xiaohongshu How to save pictures without watermark in Xiaohongshu How to save pictures without watermark in Xiaohongshu How to save pictures without watermark in Xiaohongshu Mar 22, 2024 pm 03:40 PM

Xiaohongshu has rich content that everyone can view freely here, so that you can use this software to relieve boredom every day and help yourself. In the process of using this software, you will sometimes see various beautiful things. Many people want to save pictures, but the saved pictures have watermarks, which is very influential. Everyone wants to know how to save pictures without watermarks here. The editor provides you with a method for those in need. Everyone can understand and use it immediately! 1. Click the "..." in the upper right corner of the picture to copy the link 2. Open the WeChat applet 3. Search the sweet potato library in the WeChat applet 4. Enter the sweet potato library and confirm to get the link 5. Get the picture and save it to the mobile phone album

How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? Mar 14, 2024 pm 02:07 PM

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

How to make ppt pictures appear one by one How to make ppt pictures appear one by one Mar 25, 2024 pm 04:00 PM

In PowerPoint, it is a common technique to display pictures one by one, which can be achieved by setting animation effects. This guide details the steps to implement this technique, including basic setup, image insertion, adding animation, and adjusting animation order and timing. Additionally, advanced settings and adjustments are provided, such as using triggers, adjusting animation speed and order, and previewing animation effects. By following these steps and tips, users can easily set up pictures to appear one after another in PowerPoint, thereby enhancing the visual impact of the presentation and grabbing the attention of the audience.

What is hiberfil.sys file? Can hiberfil.sys be deleted? What is hiberfil.sys file? Can hiberfil.sys be deleted? Mar 15, 2024 am 09:49 AM

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber

See all articles