access数据库是否能够存图片?
access数据库是否能够存图片?如果可以,该怎么存?我想用VB+access操作..
------解决方案--------------------        With stm
           If rs2.RecordCount > 0 Then
               .Open
               .Type = adTypeBinary
               .LoadFromFile App.Path & "DATA.jpg"
               rs2.Fields!图片 = .Read
              .Close
           End If
           .Open
           .Type = adTypeBinary
           .Write rs2.Fields!图片
           .SaveToFile Path, adSaveCreateOverWrite
           .Close
           Image1.Picture = LoadPicture(Path)
          ' rs1.Close
       End With
------解决方案--------------------可以的, 先把图片打开, 读入内存缓冲区,然后用所组去接受,然后再入库; 用的时候再出库。
void CInputpictureDlg::OnOK()  
{
	// TODO: Add extra validation here
	try	
	{
		CString id,name;
		m_id.GetWindowText(id);//从窗口给图片编号
		if(id.IsEmpty())
		{
			MessageBox("编号不能空");
			return;
		}		
		m_name.GetWindowText(name);//从窗口给图片取名字
		if(name.IsEmpty())
		{
			MessageBox("名字不能为空");
			return;
		}
		char *m_pBuffer;
		//定义内存缓冲区
		CFile file;
		//定义文件对象
		if(!file.Open(strText,CFile::modeRead))
		{
			MessageBox("不能打开文件");
			return;
		}
		//定义文件的长度
		DWORD m_filelen;
		//取得文件的长度
		m_filelen = file.GetLength();
		//根据文件的长度分配内存空间
		m_pBuffer = new char[m_filelen + 1];
		//读取图片文件到m_pBuffer中
		if(file.ReadHuge(m_pBuffer,m_filelen)!=m_filelen)
		{
			MessageBox("读取文件出错");
			return;
		}
		ADOConn m_AdoConn;
		m_AdoConn.OnInitADOConn();
		_bstr_t sql;
		sql = "select*from picture";
		_RecordsetPtr m_pRecordset;
		m_pRecordset=m_AdoConn.GetRecordSet(sql);
		//入库开始喽
		m_pRecordset->AddNew();
		VARIANT varblob;
		SAFEARRAY *psa;
		SAFEARRAYBOUND rgsabound[1];
		rgsabound[0].lLbound = 0;
		rgsabound[0].cElements = m_filelen;
		//创建数组
		psa = SafeArrayCreate(VT_UI1,1,rgsabound);
		//将m_pBuffer写入数组
		for(long i=0;i<(long)m_filelen;i++)
		{
			SafeArrayPutElement(psa,&i,m_pBuffer++);
		}	
		varblob.vt = VT_ARRAY|VT_UI1;
		varblob.parray = psa;
		m_pRecordset->GetFields()->GetItem("id")->Value = (_bstr_t)id;
		m_pRecordset->GetFields()->GetItem("name")->Value = (_bstr_t)name;
		//调用AppendChunk将图片数据写入phote字段内
		m_pRecordset->GetFields()->GetItem("photo")->AppendChunk(varblob);
		//生效喽, 断开链接喽
		m_pRecordset->Update();
		m_AdoConn.ExitConnect();
	}
	catch(...)
	{
		MessageBox("操作失败");
		return;
	}
	MessageBox("操作失败");
	}
不知道我有没有说明白, 同时对于声音文件等都是以此类推喽, (*^__^*) 嘻嘻……
------解决方案--------------------ACCESS中能存图片,但不建议存在ACCESS中。
因为,一个200K左右的图片文件,存在ACCESS中后,access文件的大小会增加10M左右。
嘿嘿,自己计算下你的硬盘能存多少图片呢?
------解决方案--------------------我觉得把图片和数据库放在同一个文件夹里,然后用插入对象的方式,调取图片就行了,