| View previous topic :: View next topic |
| Author |
Message |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Wed Sep 01, 2010 1:19 am Post subject: VdsObject Control question [Solved] |
|
|
Hi another time forum
It's possible store into a database's memo field the data of a VdsObj's Richedit control ? and how? (Using Sql's ccommand. I'm using VdsDb.dll)
I tryed with this code
| Code: |
OBJECT SAVEFILE,RICHEDIT1,TEMP.Tmp
%a = @New(LIST)
List LOADFILE,%a,TEMP.Tmp
%b = @Text(%a)
Dll Db,Query,"INSERT INTO Anamnesi VALUES("@NextId(Anamnesi)",'"@Text(%a)'')"
|
but return error
Maybe because @Text(%a) returns a string with same Carriage return symbols inside, I think
The Database's table 'Anamnesi' contains 2 fields:
1- numeric
2- Memo
Many Tnx like always for any help 
Last edited by Tdk161 on Mon Sep 06, 2010 9:25 am; edited 1 time in total |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Sep 01, 2010 4:31 am Post subject: |
|
|
Your INSERT statement is incorrect, you need to declare the fields and you missed a quote mark. Try this...
| Code: | OBJECT SAVEFILE,RICHEDIT1,TEMP.Tmp
%a = @New(LIST)
List LOADFILE,%a,TEMP.Tmp
%b = @Text(%a)
Dll Db,Query,"INSERT INTO Anamnesi (numeric, Memo)VALUES(@NextId(Anamnesi),'"@Text(%a)"')" |
I see where you quoted "@NextId(Anamnesi)", If this is a SQL function, don't put quotes around it. If it's a user defined VDS function then put quotes around it.
Yes, you can save Richedit data to a SQL DB. Edit the snippet below to your needs:
| Code: | :SaveToDB
Object savefile,RICHEDIT1,Temp.tmp
REM vdsobj.dll will cause an unnecessary event so trash it
%E = @event()
%a = @New(LIST)
List LOADFILE,%a,TEMP.Tmp
REM Check for single quotes (') and add an extra (') else it will cause a SQL error
List seek,%a,0
Repeat
%%line = @item(%a)
If @ok()
While @not(@null(%%line))
%%pos1 = @pos("'",%%line)
If @unequal(%%pos1,0)
%%newline = %%newline@substr(%%line,1,%%pos1)'
%%line = @strdel(%%line,1,%%pos1)
Else
%%newline = %%newline%%line
%%line =
End
Wend
List put,%a,%%newline
%%newline =
%%line = @next(%a)
End
Until @not(@ok())
%%Memo = @text(%a)
List close,%a
Dll Db,Query,"INSERT INTO Anamnesi (numeric, Memo)VALUES(@NextId(Anamnesi),'"%%Memo"')" |
Hope that helps,  |
|
| Back to top |
|
 |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Wed Sep 01, 2010 11:05 am Post subject: |
|
|
Hi Aslan,
I will try your code
Only one question:
to read data from db memo fields and use in an Richedit control, I must only read and put text into control?
Tnx and Byez |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Sep 02, 2010 11:58 pm Post subject: |
|
|
| Code: | :GetAllDataFromDB
REM This will show all DB data in RICHEDIT1
Dll Db,Query,"Select * from Anamnesi"
repeat
Dll Db fetchrow
If @ok()
%%numeric = @Dll(Db,Get,numeric)
%%Memo = @Dll(DB,Get,Memo)
OBJECT Append,RICHEDIT1,Item %%numeric
OBJECT Append,RICHEDIT1,""
OBJECT Append,RICHEDIT1,%%Memo
OBJECT Append,RICHEDIT1,""
OBJECT Append,RICHEDIT1,""
End
Until @Not(@Ok())
Dll Db Disconnect
|
| Code: | :GetSelectedDataFromDB
REM This will show selected (value of %%numeric) DB data in RICHEDIT1
Dll Db,Query,"Select Anamnesi.[Memo] from Anamnesi Where Anamnesi.[numeric] = '"%%numeric"'"
Dll Db fetchrow
If @ok()
%%numeric = @Dll(Db,Get,numeric)
%%Memo = @Dll(DB,Get,Memo)
OBJECT Append,RICHEDIT1,Item %%numeric
OBJECT Append,RICHEDIT1,""
OBJECT Append,RICHEDIT1,%%Memo
End
Dll Db Disconnect
|
You can also put the DB data in a list then use Object set,RICHEDIT1,@text(<ListId>).
This will clear the RICHEDIT control each time and only show the data you just set. |
|
| Back to top |
|
 |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Mon Sep 06, 2010 9:24 am Post subject: |
|
|
Hi Aslan
Your code work fine, but I must changed Sql command, with mdb file (in my pc) sql standard command not work I used my old code (it's worked like always), but you code to save rich edit text in a db memo file work
Many tnx
byez |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|