Welcome! Log In Create A New Profile

Advanced

Don Schwirtlich: Add data to a file - webdev 23

Posted by harvey68 
Don Schwirtlich: Add data to a file - webdev 23
September 08, 2018 06:39PM
Autor: Don Schwirtlich

Link zum Beitrag: [27130.foren.mysnip.de]

Can someone point me to a tutorial or example of data being added to a
file - the pcsoft version of my previous life (clarion) - would be

File1.Field1 = 'Stuff'
File1.Field2 = ' more stuff''
File1.field3 = 'even more stuff'
Access.File1.Insert()

And I know HAdd(File1) - would come in there somewhere.

Thanks in advance

Don
rob willis: Add data to a file - webdev 23
September 08, 2018 06:40PM
Autor: rob willis

Link zum Beitrag: [27130.foren.mysnip.de]

So I am a SQL guy thus provided your analysis has been configured.

Hreset(mytablename) // clears the record
Mytablename.LastName = "Willis"
Mytablename.FirstName = "Robert"
Mytablename.Userid = "rwillis@blackwrist.com"
Hadd(mytablename)

Now the thing I learned late was this next part.

myuserprimarykey = mytablename.primarykeycolumnname // this was if you
have an autoincrementing primary key column it will return it to the
variable you defined.
Don Schwirtlich: Add data to a file - webdev 23
September 08, 2018 06:41PM
Autor: Don Schwirtlich

Link zum Beitrag: [27130.foren.mysnip.de]

Thanks Rob Willis

Best regards,

Don Schwirtlich
Don Schwirtlich: Add data to a file - webdev 23
September 08, 2018 06:41PM
Autor: Don Schwirtlich

Link zum Beitrag: [27130.foren.mysnip.de]

How could I screw up something this simple... what can you see that i
am doing wrong,

HReset(Logins)
Logins.EMAIL = EDT_EMAIL
Logins.Password = EDT_Password
HAdd(Logins)


Other than an autoID Logins.LoginsID - that is all in this data file of
this analysis.

Don
Arie: Add data to a file - webdev 23
September 08, 2018 06:42PM
Autor: Arie

Link zum Beitrag: [27130.foren.mysnip.de]

Don,

I don't see anything worng with that.

Which type of database do you use and how do you setup a connection to
it?

You can, during desingtime, define a connection in the analysis. But
most of the time at runtime your database sits somewhere else.
Then you need to define a connection and link that to your tables (files
in WD terms…).

Take a look in the help for HOpenConnection() to setup and open a
connection (I do that with settings coming from an inifile) and
HChangeConnection() to link this connection to your tables/files.

If you do nothing and you have defined your connection (design time) as
HFclassic you will end up with a local file Mytablename.fic somewhere on
you disk.

I also would check the result of your HAdd() to see if there might be an
error. Or use the debugger to step through your code and check the
result when on the HAdd-line.
IF NOT HAdd() THEN
Error(ErrorInfo())
END
DarrenF: Add data to a file - webdev 23
September 08, 2018 06:43PM
Autor: DarrenF

Link zum Beitrag: [27130.foren.mysnip.de]

Don,

Based on some of your previous posts I'm not sure if you've given up on
the WB tutorial?

There's a section in there showing you how to manage HAdd's etc... along
with using the ScreenToFile function for moving values from edit
controls to the file buffer before issuing the HAdd thus saving lots of
coding when your windows (and files) files have lots of fields. I would
take a look at this while considering Arie's valid comments.

I'm looking at an old version of the WB tutorial when I say this but the
section is called "Lesson 2.4. Edit Page" and discusses Creating an edit
page but also includes Managing the addition of a record and Managing
the search and the modification.
Don Schwirtlich: Add data to a file - webdev 23
September 08, 2018 06:44PM
Autor: Don Schwirtlich

Link zum Beitrag: [27130.foren.mysnip.de]

I have done the tutorial - and my adds went great - viewed the file ,
checked out the records I added , no problem. The difference that I can
tell , which surely isnt the one biting me here - is that instead of
doing the screentofile, doing the moving of values from edit controls.
But I did change that to screentofile - and still didnt work. Has to be
the connect - my day job is spent on a 30 year old legacy desktop app,
so I get a little jaded when i switch to pcsoft stuff. Thanks and will
keep looking.

Don
Don Schwirtlich: Add data to a file - webdev 23
September 08, 2018 06:45PM
Autor: Don Schwirtlich

Link zum Beitrag: [27130.foren.mysnip.de]

Many thanks Darren, Arie, adding the Error(ErrorInfo()) told me
everything. There was an issue in the cardinalities (sp?) between the
keys in the link between two of my files. For testing, i removed the
link - reran the register piece, and data is there. Now to go see what
my error was in the dictionary. Fixing one mistake at a time.

Thanks again and best regards,

Don
rob willis: Add data to a file - webdev 23
September 08, 2018 06:45PM
Autor: rob willis

Link zum Beitrag: [27130.foren.mysnip.de]

Can't agree more with Don/Arie.

IF NOT HADD(MyTableName) then
info(Herrorinfo())
end

Things that can go wrong are a primary key constrainst, or in your
example your the length of email or password exceeds the column
definition. for example if you made email a varchar(20) and tried to
stick 21+ chars into it.
rob willis: Add data to a file - webdev 23
September 08, 2018 06:46PM
Autor: rob willis

Link zum Beitrag: [27130.foren.mysnip.de]

Don

For what its worth, I had the same dark days initially with Wxdev. I
did Clarion in the 90's and then Powerbuilder, etc. So when I
purchased Wxdev for my projects it was a risky investment to make it
work. I'm a DBA by trade so moving data in and out was paramount to my
accepting this product.

If you can invest a little more time (and maybe money) is Glenn Rathke's
materials. wxtraining.net They got me over the hump. I personally have
NOT looked at Fabrice's materials which are pinned to this forum, but
he's a Wx rockstar as well and frequents his board.

So I will take it for granted that you'll quickly get over this bump and
your next one is going to be ok, I can add data to the table defined in
the analysis but how do I now point to a different database server? I
develop to my dev server but how to point elsewhere?

check out documentation on the next couple of items.

gsSdbuser = INIRead("Main" ,"mUser", "","gmic.ini" )
gsSdbserver = INIRead("Main" ,"mServer", "","gmic.ini" )
gsSdbname = INIRead("Main" ,"mDatabase", "","gmic.ini" )
gsSdbpassword = INIRead("Main" ,"mPassword", "","gmic.ini" )

ProdConnection is connection // connection is variable type.

// Describe the connection
ProdConnection..User = gsSdbuser
ProdConnection..Password = gsSdbpassword
ProdConnection..Server = gsSdbserver
ProdConnection..Database = gsSdbname
ProdConnection..Provider = hOledbSQLServer
ProdConnection..Access = hOReadWrite
//
//

HChangeConnection("*",prodconnection)

what all this does is read an ini file, create a new db connection and
point all the current tables to the new connection
Don Schwirtlich: Add data to a file - webdev 23
September 08, 2018 06:47PM
Autor: Don Schwirtlich

Link zum Beitrag: [27130.foren.mysnip.de]

I agree with you , any of these guys that puts their time and rep on the
line, I am going to jump in, Glenn, soon, Fabrice 's stuff has helped me
a bunch as well. As well as the advice from so many here.

I , in my search for 'whats next' when I realized Clarion wasnt going to
get there, researched , bought, downloaded, trial purchased, 11
different platforms - I kept thinking how in the heck has someone not
done - what I finally found out that pcsoft had done. I keep getting up
every morning and thinking that big GOTCHA is going to bite my ample
rear end - but so far everything has been minor, very minor compared to
the other toys i messed with.

Best regards,

Don
Fabrice Harari: Add data to a file - webdev 23
September 08, 2018 06:48PM
Autor: Fabrice Harari

Link zum Beitrag: [27130.foren.mysnip.de]

Hi Don,

Just to reassure you a little bit... I have been working with WinDev for
about 25 years now (I started with version 1.5)...

During that time, I have NEVER met a situation that I coudln't deal with
using WinDev, WebDev and WinDev Mobile, even though some of the
requirements I was given were borderline crazy...

So I think your backside is safe

Best regards
Don Schwirtlich: Add data to a file - webdev 23
September 08, 2018 07:02PM
Autor: Don Schwirtlich

Link zum Beitrag: [27130.foren.mysnip.de]

Good to hear, Fabrice, since my 'backside' is quite large as well, so it
being safe, is 'big' to me.

Best regards,

Don
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: