CLOB, BLOB I'm confused...

  • Thread starter Thread starter EMW
  • Start date Start date
E

EMW

I have a table in a dataset with 4 columns.
Except for the third, all columns are NVARCHAR2.

The third is a CLOB. I read it can hold up to 4Gb.

The column of the dataset is bound with a textbox, so the datalimit is 32kb.

But when I store more then 4000 characters into the dataset and then write
the row in to the oracle database (with an INSERT INTO sql line) , I get an
error. "ORA-01704"

I've read somewhere it is possible to write more then 4000 characters at
once into the database, but I can't seem to find the right documentation for
it.

Can anyone give me some pointers on how to do this, or some links of pages
where a good explaination can be found?
References to books is of no use, can't afford them at the moment.

rg,
Eric
 
4000 characters is the limit for nvarchar2
Are you having problems with nvarchar2 or clob?
 
I had problems with storing data in a CLOB.

But I created a way around it, allthough I hope there is a shorter and
faster way.

I first write the contents of the richtextbox to a file with it's own
command, then I read it back into a bytearray and place that in the dataset.
Then I update the database with the dataset. I now use BLOB instead of CLOB.

I would like it if there is a way of doing this without writing and reading
the file.

rg,
Eric



Miha Markic said:
4000 characters is the limit for nvarchar2
Are you having problems with nvarchar2 or clob?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

EMW said:
I have a table in a dataset with 4 columns.
Except for the third, all columns are NVARCHAR2.

The third is a CLOB. I read it can hold up to 4Gb.

The column of the dataset is bound with a textbox, so the datalimit is 32kb.

But when I store more then 4000 characters into the dataset and then write
the row in to the oracle database (with an INSERT INTO sql line) , I get an
error. "ORA-01704"

I've read somewhere it is possible to write more then 4000 characters at
once into the database, but I can't seem to find the right documentation for
it.

Can anyone give me some pointers on how to do this, or some links of pages
where a good explaination can be found?
References to books is of no use, can't afford them at the moment.

rg,
Eric
 
Hi Eric,

A complet sample I did make and send also today in another newsgroup.

It is a complete answer (I used in the sample a xmlfile as the database, to
keep the sample stand alone).

\\\
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Reading a picture and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a dataset
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType =
System.Type.GetType("System.Byte[]")
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyt
Dim sf As New SaveFileDialog
If sf.ShowDialog = DialogResult.OK Then
ds.WriteXml(sf.FileName, XmlWriteMode.WriteSchema)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a dataset
Dim ds As New DataSet
If fo.ShowDialog = DialogResult.OK Then
ds.ReadXml(fo.FileName)
End If
abyt = CType(ds.Tables(0).Rows(0)(0), Byte())
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub

I hope this helps a little bit?

Cor
 
Thanks Cor!

But I already had something simulair.
It's basicly the same as what I have ;)

Thanks anyway, it is appreciated!
 
Back
Top