C#读写Access数据库的OLE对象字段
(一)把文件内容写入Access数据库的OLE对象字段中:
if (File.Exists(txtBrow.Text) != false) // 文本框txtBrow中内容为文件路径及文件名
{
//获取文件后缀
FileInfo p = new FileInfo(txtBrow.Text.Trim());
F_str_Type = p.Extension.ToLower();
if (F_str_Type.Length > 5)
{
MessageBox.Show("不可识别的文件格式,请重新确认!","警告");
return;
}
//判断文件大小
if (p.Length == 0)
{
MessageBox.Show("文件的大小为“0”,不能保存!", "警告");
return;
}
//创建文件对象以打开的形式读取文件
FileStream sFileStream = new FileStream(txtBrow.Text, FileMode.Open);
//分配数组大小
byte[] bFile = new byte[sFileStream.Length];
//将文件内容读进数组
sFileStream.Read(bFile, 0, (int)sFileStream.Length);
//关闭文件对象
sFileStream.Close();
//查找文档类别号
OleDbDataReader topicread = SaveConn.GetReader("select File_ID from FileTopic where File_Topic='" + cbbTopic.Text.Trim() + "'");
//Read()方法用来读取OleDbDataReader对象中的记录
topicread.Read();
T_int_Topic=(int)topicread["File_ID"];
OleDbConnectio
相关文档:
1,在web服务器上安装Oracle数据库客户端,这是连接Oracle数据库的基础(但,不一定是必须的)。
2,在客户端的Net Manager 中进行配置服务的名称,配置如图(这一点非常的重要以后的链接全都在这个服务名称的基础上进行的)
3,ASP链接服务的链接字符串和方法如下:
<%
connstr= "Provider=MSDAORA.1;Password=***; ......
#include "iostream.h"
#include "stdio.h"
#import "C:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
int main(int argc, char* argv[])
{
::CoInitialize(NULL);
_ConnectionPtr m_pConnection;
m_pConnection.CreateInstance("ADODB.Connection");
tr ......
SqLite.net的dll为System.Data.SQLite.dll,这种dll分为32位、64位和适用于compactframework三种,在引用时要注意,选择正确的dll。
将要保存图片的字段类型设为blob。代码如下:
private void savePicture()
{
using (SQLiteConnection cnn = new SQLiteConnection(dbPath))
......
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.comboBox2.Items.Clear();
switch(this.comboBox1.SelectedIndex)
  ......