forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


VdsObject Control question [Solved]

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Wed Sep 01, 2010 1:19 am    Post subject: VdsObject Control question [Solved] Reply with quote

Hi another time forum Wink

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 Question
The Database's table 'Anamnesi' contains 2 fields:
1- numeric
2- Memo

Many Tnx like always for any help Smile


Last edited by Tdk161 on Mon Sep 06, 2010 9:25 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Sep 01, 2010 4:31 am    Post subject: Reply with quote

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, Wink
Back to top
View user's profile Send private message Send e-mail
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Wed Sep 01, 2010 11:05 am    Post subject: Reply with quote

Hi Aslan,

I will try your code Smile

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
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Thu Sep 02, 2010 11:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Mon Sep 06, 2010 9:24 am    Post subject: Reply with quote

Hi Aslan Smile
Your code work fine, but I must changed Sql command, with mdb file (in my pc) sql standard command not work Sad I used my old code (it's worked like always), but you code to save rich edit text in a db memo file work Smile
Many tnx

byez
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group