Lists: | pgsql-odbc |
---|
From: | Matthew Dormer <matt(at)infosource(dot)com(dot)au> |
---|---|
To: | pgsql-odbc(at)postgresql(dot)org |
Subject: | Writing Large Objects to Postgresql via ODBC using VB |
Date: | 2001-05-02 06:32:19 |
Message-ID: | 5.0.2.1.2.20010502162018.00a649c0@mail.infosource.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-odbc |
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
From: | "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> |
---|---|
To: | "Matthew Dormer" <matt(at)infosource(dot)com(dot)au> |
Cc: | <pgsql-odbc(at)postgresql(dot)org> |
Subject: | RE: Writing Large Objects to Postgresql via ODBC using VB |
Date: | 2001-05-04 15:15:31 |
Message-ID: | EKEJJICOHDIEMGPNIFIJGEIPEEAA.Inoue@tpf.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-odbc |
> -----Original Message-----
> From: Matthew Dormer
>
> 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:
>
Hmm you are using RDO.
Are you setting rdoEnvironments.CursorDriver to rdUseOdbc ?
regards,
Hiroshi Inoue
From: | Matthew Dormer <matt(at)infosource(dot)com(dot)au> |
---|---|
To: | "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> |
Cc: | pgsql-odbc(at)postgresql(dot)org |
Subject: | RE: Writing Large Objects to Postgresql via ODBC using VB |
Date: | 2001-05-10 23:59:22 |
Message-ID: | 5.0.2.1.2.20010511094427.00a6bec0@mail.infosource.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-odbc |
At 12:15 AM 5/5/01 +0900, you wrote:
> > -----Original Message-----
> > From: Matthew Dormer
> >
> > 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:
> >
>
>Hmm you are using RDO.
>Are you setting rdoEnvironments.CursorDriver to rdUseOdbc ?
>
>regards,
>Hiroshi Inoue
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
When I connect to the database I use:
Dim Server As New Database_Servers
Dim Connect_String As String
If Server.dbDriver(DBid) = "SQL Server" Then
Connect_String = "UID=" & Server.User_Name(DBid) & _
";PWD=" & Server.User_Password(DBid) & _
";Driver={" & Server.dbDriver(DBid) & _
"};SERVER=" & Server.dbServer(DBid) & _
"," & Server.dbServerPort(DBid) & _
";DATABASE=" & Server.dbName(DBid)
Else
Connect_String = "UID=" & Server.User_Name(DBid) & _
";PWD=" & Server.User_Password(DBid) & _
";Driver={" & Server.dbDriver(DBid) & _
"};SERVER=" & Server.dbServer(DBid) & _
";DATABASE=" & Server.dbName(DBid)
End If
Set en = rdoEnvironments(0)
en.CursorDriver = rdUseOdbc
Set cn = en.OpenConnection( _
dsname:="", _
Connect:=Connect_String _
, Prompt:=rdDriverNoPrompt)
Ok... I added in the en=CoursorDriver = rdUseODBC and now I am getting:
S1090: [Microsoft][ODBC Driver Manager] Invalid String or buffer length
Any Ideas?
Matt.