RE: Writing Large Objects to Postgresql via ODBC using VB - Mailing list pgsql-odbc
From | Henshall, Stuart - WCP |
---|---|
Subject | RE: Writing Large Objects to Postgresql via ODBC using VB |
Date | |
Msg-id | E2870D8CE1CCD311BAF50008C71EDE8E01F745A5@MAIL_EXCHANGE Whole thread Raw |
In response to | Writing Large Objects to Postgresql via ODBC using VB (Matthew Dormer <matt@infosource.com.au>) |
Responses |
Re: RE: Writing Large Objects to Postgresql via ODBC
using VB
|
List | pgsql-odbc |
Hello, I'm not sure of your problem, but 6.5 seems a little old so maybe an update would help? Also you don't give you primary key a value (and its set to Not Null) so this look to be a problem. Try having a look at the serial type rather than integer for matt.matt_id Hope this helps, - Stuart P.S. do you need to do anything like rst.Edit using before entering data? > -----Original Message----- > From: Matthew Dormer [SMTP:matt@infosource.com.au] > Sent: Wednesday, May 02, 2001 7:32 AM > To: pgsql-odbc@postgresql.org > Subject: Writing Large Objects to Postgresql via ODBC using VB > > 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 >
pgsql-odbc by date: