--____LPHMXLZMXOMRLFKSEJCW____
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,
I am trying to save some rtf code from an rtf field to a TEXT field on =
SQL2000.
The code I have been playing with (thanks to Nick for the originally =
supplied code!) is:
Sub DoByteConversion()
Dim pBytStuff As Byte() =3D StringToArray(Rtxt_readme.Rtf) =
'convert rtf field to byte array
Dim pDBNConnection As OleDbConnection
Dim pDBCCommand As OleDbCommand
pDBNConnection =3D New OleDbConnection
pDBNConnection.ConnectionString =3D Globals.udl0Val 'take udk =
connection from Globals Class
Call pDBNConnection.Open()
If (pDBNConnection.State =3D ConnectionState.Open) Then
pDBCCommand =3D pDBNConnection.CreateCommand
pDBCCommand.CommandText =3D "UPDATE TestsConfig Set ReadMe =3D =
@bits Where Type =3D '" & TestSelected & "'"
pDBCCommand.CommandTimeout =3D 20
Call addParameter(pDBCCommand, "bits", pBytStuff)
If (pDBCCommand.ExecuteNonQuery() > 0) Then
'OPERATION WAS FINE!
End If
End If
End Sub
Public Function getOleDbType(ByVal iType As Type) As OleDbType
If (iType Is GetType(String)) Then
Return OleDbType.VarChar
ElseIf (iType Is GetType(Integer)) Then
Return OleDbType.Integer
ElseIf (iType Is GetType(Boolean)) Then
Return OleDbType.Boolean
ElseIf (iType Is GetType(Date)) Then
Return OleDbType.Date
ElseIf (iType Is GetType(Char)) Then
Return OleDbType.Char
ElseIf (iType Is GetType(Decimal)) Then
Return OleDbType.Decimal
ElseIf (iType Is GetType(Double)) Then
Return OleDbType.Double
ElseIf (iType Is GetType(Single)) Then
Return OleDbType.Single
ElseIf (iType Is GetType(Byte())) Then
Return OleDbType.Binary
ElseIf (iType Is GetType(Guid)) Then
Return OleDbType.Guid
End If
End Function
Public Sub addParameter(ByVal iCommand As OleDbCommand, ByVal =
iParameter As String, _
ByVal iValue As Object)
If (iCommand.CommandText.IndexOf(iParameter) <> -1) Then
Dim pODPParameter As OleDbParameter =3D _
iCommand.Parameters.Add(iParameter, getOleDbType(iValue.GetType=
))
pODPParameter.Value =3D iValue
End If
End Sub
However when I run this it I just get an unhandled exception in Data.Dll
Any ideas would be appreciated!
Cheers
Adam
--____LPHMXLZMXOMRLFKSEJCW____
Content-Type: multipart/related; boundary="____WHPEPQYSAQXEHDGESJXG____"
--____WHPEPQYSAQXEHDGESJXG____
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1"=
>
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR></HEAD>
<BODY style=3D"MARGIN: 4px 4px 1px; FONT: 8pt Tahoma; COLOR: #000000">
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>I am trying to save some rtf code from an rtf field to a TEXT =
field on SQL2000.</DIV>
<DIV> </DIV>
<DIV>The code I have been playing with (thanks to Nick for the originally =
supplied code!) is:</DIV>
<DIV>Sub DoByteConversion()</DIV>
<DIV> </DIV>
<DIV> Dim pBytStuff As Byte() =
=3D StringToArray(Rtxt_readme.Rtf) 'convert rtf field to byte array</DIV>
<DIV> </DIV>
<DIV> Dim pDBNConnection As =
OleDbConnection<BR> Dim =
pDBCCommand As OleDbCommand<BR> =
pDBNConnection =3D New OleDbConnection<BR> &nb=
sp; pDBNConnection.ConnectionString =3D Globals.udl0Val 'take udk =
connection from Globals Class<BR> =
Call pDBNConnection.Open()<BR> =
If (pDBNConnection.State =3D ConnectionState.Open) Then<BR> &nbs=
p; pDBCCommand =3D =
pDBNConnection.CreateCommand<BR> &=
nbsp; pDBCCommand.CommandText =3D "UPDATE TestsConfig =
Set ReadMe =3D @bits Where Type =3D '" & TestSelected & "'"<BR>&nbs=
p; pDBCCommand.=
CommandTimeout =3D 20<BR> &n=
bsp; Call addParameter(pDBCCommand, "bits", pBytStuff)<BR> =
; If (pDBCComma=
nd.ExecuteNonQuery() > 0) Then<BR> &n=
bsp; 'OPERATION WAS =
FINE!<BR> =
End If<BR> End If<BR>  =
; End Sub<BR> Public Function getOleDbType(ByVal =
iType As Type) As OleDbType<BR> =
If (iType Is GetType(String)) Then<BR> &=
nbsp; Return OleDbType.VarChar<BR>  =
; ElseIf (iType Is GetType(Integer)) Then<BR> =
Return =
OleDbType.Integer<BR> ElseIf =
(iType Is GetType(Boolean)) Then<BR> &nb=
sp; Return OleDbType.Boolean<BR> &=
nbsp; ElseIf (iType Is GetType(Date)) Then<BR>  =
; Return OleDbType.Da=
te<BR> ElseIf (iType Is =
GetType(Char)) Then<BR> &nbs=
p; Return OleDbType.Char<BR>  =
; ElseIf (iType Is GetType(Decimal)) Then<BR> =
Return OleDbType.Decimal<BR>&nbs=
p; ElseIf (iType Is GetType(Double)) =
Then<BR> =
Return OleDbType.Double<BR> =
ElseIf (iType Is GetType(Single)) Then<BR> &nb=
sp; Return OleDbType.Single<BR> &n=
bsp; ElseIf (iType Is GetType(Byte())) Then<BR>&nbs=
p; Return =
OleDbType.Binary<BR> ElseIf =
(iType Is GetType(Guid)) Then<BR> =
Return OleDbType.Guid<BR> &=
nbsp; End If<BR> End Function</DIV>
<DIV> </DIV>
<DIV> Public Sub addParameter(ByVal iCommand As =
OleDbCommand, ByVal iParameter As String, _<BR> &nbs=
p; &=
nbsp; ByVal iValue =
As Object)</DIV>
<DIV> </DIV>
<DIV> If (iCommand.CommandText.In=
dexOf(iParameter) <> -1) Then<BR> =
Dim pODPParameter As OleDbParameter =3D =
_<BR> =
iCommand.Parameters.Add(iParameter, getOleDbType(iValue.GetType))<BR> =
pODPParameter.=
Value =3D iValue<BR> End =
If<BR> End Sub</DIV>
<DIV> </DIV>
<DIV>However when I run this it I just get an unhandled exception in =
Data.Dll</DIV>
<DIV> </DIV>
<DIV>Any ideas would be appreciated!</DIV>
<DIV> </DIV>
<DIV>Cheers</DIV>
<DIV>Adam</DIV></BODY></HTML>
--____WHPEPQYSAQXEHDGESJXG____--
--____LPHMXLZMXOMRLFKSEJCW____--