database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 2987 게시물 읽기
No. 2987
Writing Large Objects to Postgresql via ODBC using VB
작성자
정재익
작성일
2001-06-21 23:01
조회수
1,848

원본출처 : http://zeus.sai.msu.ru:8000/mhonarc/pgsql-odbc/2001-05/msg00011.html

 

 

Writing Large Objects to Postgresql via ODBC using VB

 

--------------------------------------------------------------------------------

 

From: Matthew Dormer <matt@infosource.com.au>

To: pgsql-odbc@postgresql.org

Subject: Writing Large Objects to Postgresql via ODBC using VB

Date: Wed, 02 May 2001 16:32:19 +1000

 

--------------------------------------------------------------------------------

 

I am having problems writing to a postgres database using ODBC. Here are

the steps I have taken:

 

1. I have greated a lo type in the database

 

create type lo (

internallength=4, externallength=10,

input=int4in, output=int4out,

default='', passedbyvalue

);

 

 

2. I create a table in the database

 

Create table matt ( matt_id integer not null unique primary key, matt_text

lo );

 

3. I have a simple form with 1 rich text box, RichTextBox1 and a command

button Command 1 Here is the code on the form:

 

 

Private Sub Command1_Click()

 

Dim query As rdoQuery

Dim rst As rdoResultset

 

Set query = cn.CreateQuery("Add_Pic", "select * from matt;")

Set rst = query.OpenResultset(1, 3)

 

rst.AddNew

Save_RichText RichTextBox1, rst![matt_pic]

rst.Update

 

End Sub

 

 

Public Function Save_RichText(TextBox1 As RichTextBox, WhatField As rdoColumn)

 

Dim DataFile As Integer ' Free File Number fo Reading

Dim Fl As Long ' Length of the File

Dim Chunks As Integer ' The Number of Chunks

Dim Fragment As Integer ' The Size of the Remainder

Dim Chunk() As Byte ' To hold each Chunk

Dim I As Integer ' Variable for For Loop

 

Const FileName = "c:\tmpsavetext.rtf"

Const ChunkSize As Integer = 1024

 

TextBox1.SaveFile FileName, rtfRTF

DataFile = FreeFile

 

Open FileName For Binary Access Read As DataFile

Fl = LOF(DataFile) ' Length of data in file

If Fl = 0 Then Close DataFile: Exit Function

Chunks = Fl \ ChunkSize

Fragment = Fl Mod ChunkSize

 

'Put Null into Field

WhatField.AppendChunk Null

 

'Get the Fragment

ReDim Chunk(Fragment)

Get DataFile, , Chunk()

WhatField.AppendChunk Chunk()

 

'Get the Chunks

ReDim Chunk(ChunkSize)

For I = 1 To Chunks

Get DataFile, , Chunk()

WhatField.AppendChunk Chunk()

Next I

 

Close DataFile

Kill FileName

 

End Function

 

 

What is wrong with the above. when I run it i get the error:

 

S1C00: Only SQL_POSITION/REFRESH is supported for SQLSetPos

 

I am running postgresql 6.5.3, PostgreSQL ODBC Driver v 6.50.0000 and am

using vb 6.0 Enterprise. The postgresql was installed from a rpm and is

running on RedHat 6.2

 

Any help would be greatly Appreciated.

 

Matt Dormer

[Top]
No.
제목
작성자
작성일
조회
2990Tree-structure functions (3)
정재익
2001-06-21
1680
2989Tree-structure functions (2)
정재익
2001-06-21
1967
2988Tree-structure functions (1)
정재익
2001-06-21
2080
2987Writing Large Objects to Postgresql via ODBC using VB
정재익
2001-06-21
1848
2986Porting Access97 data to PostgreSQL
정재익
2001-06-21
2204
2984대.소문자 구분에 관하여...
초보자
2001-06-21
1816
2985┕>Re: 대.소문자 구분에 관하여...
정재익
2001-06-21 13:39:03
1883
2980있자나요...급질문인데요...
은미
2001-06-20
1632
2982┕>Re: 있자나요...급질문인데요...
정재익
2001-06-20 14:10:02
1917
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.020초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다