Solved

Plz help a newbie!

Posted on 2001-08-29
10
332 Views
Last Modified: 2013-12-26
I'm using PB8 Eval
My objective is very simple, just to show all record in grid view! This I've done... I've created a DataWindow with Grid style and attached it into Window object. (In DataWindow I can preview it!) But in the runtime It doesn't seem to show somethings, just a blank! So I can't figure out how to coding it to show all record like preview's time! I'm a very newbie on PB

Thanks very much all experts,
newbie to PB
drvannacult
0
Comment
Question by:DrVannacult
  • 7
  • 3
10 Comments
 
LVL 3

Expert Comment

by:pbguy
ID: 6437798
Hi Doc!

Let's see if I can get you through... I'll list the steps you need to get data displayed on a datawindow on your screen.  Let me know what you did/didn't do :

1.Create a datawindow object using the datawindow painter.

2.Create a window object using the window painter.  Add a datawindow control to the window object.  Associate the datawindow object you created with the datawindow control (do this by clicking on the datawindow control and entering the datawindow object name on the properties tab under "DataObject".)

3. Ok, you probably did all that already.  Now a couple things that you may not have done.  First, you need to make sure the application is connected to the database.  You can do this in the application's "open" event.  We'll use the default transaction object - called SQLCA - to connect to the database.  You may get away with just the following command (in the app open event) :

CONNECT USING SQLCA;  

-or- you may need to set some parms before connecting, such as :

// Profile ID2
SQLCA.DBMS = "O73 ORACLE 7.3"
SQLCA.LogPass = <***>
SQLCA.ServerName = "whatever"
SQLCA.LogId = "whatever"
SQLCA.AutoCommit = True

CONNECT USING SQLCA

but DON'T PANIC!  If the simple CONNECT USING SQLCA" command doesn't work for ya, I've got an easy way to get those parameters without going nuts!  To sum up, add the following code to your application's "open" event :


CONNECT USING SQLCA
IF SQLCA.SQLCode <> 0 THEN
          MessageBox("Connect Failed", &
               "Cannot connect to database " &
               + SQLCA.SQLErrText)
END IF


4. Ok, now that we have a window with a datawindow control attached and a connection to the database, we can get down to business.  Before you can show data, you need to set a transaction object, which essentially attaches the database to the datawindow.  For your test, you can create a command button and put this code in the "clicked" event :

// Set the transaction object to SQLCA.
dw_1.SetTransObject(SQLCA)

// And now you can retrieve the data
dw_1.Retrieve()


-- Note I assume that you named your datawindow control "dw_1".  If not, substitute the name of your datawindow control for dw_1 (IMPORTANT - NOT THE DATAWINDOW OBJECT NAME! )


Ok, this is a start for ya - let me know how you make out !

-- Bill

0
 

Author Comment

by:DrVannacult
ID: 6439134
Ok, thanks ya for ur comments

I've did it with

//Begin
CONNECT USING SQLCA;
IF SQLCA.SQLCode <> 0 THEN
         MessageBox("Connect Failed", &
              "Cannot connect to database " &
              + SQLCA.SQLErrText);
END IF
//End

In the Application's open events.
And the messagebox is appeared with message
"Cannot connect to database DBMS is not supported in your current installation."
So what's that means? Did my PB8 eval not properly installed? What should I do now? please guide me. 8)

Thanks for your comment,
drvannacult
0
 

Author Comment

by:DrVannacult
ID: 6439138
I'll try to install PB8 again to try it while I'm waiting for your answers....

8)
respect to all expert!
0
 

Author Comment

by:DrVannacult
ID: 6439424
OiC! Coooool
I can made it works now!
by COPY-'n-PASTE from DB Profile's Syntax to Script Editor.
It's look like these...

SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='DSN=TEST_PB;UID=;PWD=;'"
CONNECT USING SQLCA;
dw_myown.SetTransObject(SQLCA)
dw_myown.Retrieve()

It's worked right now! Thanks u much for guiding me to the star!
8)

Oh! But I have somethings to ask u before I give u all 50 points. What's about the .AutoCommit property? Why your code is set it to True but In the DB Profile's syntax It gonna be False.

Thanks again!
an expert...
drvannacult
0
 

Author Comment

by:DrVannacult
ID: 6439436
If It possible, I have some more question to ask to u.
How can I manipulating my data in DataWindow?
Because the things I did above look like a read-only dataset. How can I make it editable,appendable also delete. Maybe I say about .InsertRow() but I thinks there is a better way to do these such things since I thinks It should be easier because PB is a Database-Application-IDE.(I thinks that's no-need to coding about Append,Delete,Edit anymore maybe It has an automatically method to do that.)

8)
Thanks very much,
If u can guide me again, I'll put the point to 75 or above! for u only one!
8)

drvannacult
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:DrVannacult
ID: 6439439
I did it!
I need your help!
Thanks ya!

8)
drvannacult
0
 
LVL 3

Expert Comment

by:pbguy
ID: 6441110
Hi doc.  Glad I can help!  I'll do 1 at a time for you.

Autocommit : You can set Autocommit to TRUE or FALSE.

When you set Autocommit = FALSE, the Powerbuilder application performs a SQL BEGIN TRANSACTION as soon as the application opens and immediately after every commit.  This means that you always have a SQL transaction open while you are in your app.  The good thing about this is that you never need to worry about starting a transaction - you just need to commit or rollback.  The bad thing is that it leaves a transaction open at all times, and this can cause you database issues when you go to truncate a log or forget to commit.  The general consensus is that Autocommit=false is bas.

On the other hand, autocommit=true is good.  Left alone, it automatically commits your transaction as soon as you update (never hangs an open transaction.)  If you want to do a multi - table update, you can fire an explicit "BEGIN TRANSACTION" and do your own transaction handling.  This is the best way to go (just remember that Autocommit is false by default - you need to explicitly set it to true.)

Good question and good stuff to know - most PB newbies ignore this and regret it later on!




0
 
LVL 3

Accepted Solution

by:
pbguy earned 100 total points
ID: 6441196
I'll try to get you going with datawindows, but my best suggestion to you is to read up in the help topics in your PB eval - PB's help is pretty awesome for this type of stuff.

In order to make a field to be editable, you need to set a "tab order" for the column in the datawindow object.  Open up your datawindow object and choose the "Tab Order" option under the "Format" menu.  You'll see little red numbers appear next to your input fields.  Click on the number and change it to something other than 0 and they will become editable in your app.

For manipulation, look at help under "Datawindow methods" - you've got tons of getters and setters to play with.  

You've gotta code your own InsertRow() and DeleteRow() s for your application - but that's a good thing 'cause you have total control and the methods are straight forward and easy to implement!

Some tips that will save you time :

Always do an "AcceptText" in your datawindow before you update.  An update command might look something like this :

dw_1.AcceptText()
dw_1.Update()
COMMIT USING SQLCA;

(of course, you should check return codes...)

Hope this helped - good luck and have fun!

-- Bill






0
 

Author Comment

by:DrVannacult
ID: 6443839
All works for me!!!
Met at the next time!
8)

Thanks u very much for ur guiding/help...
Thanks expert! I'm very happy for ur comments!
drvannacult
0
 

Author Comment

by:DrVannacult
ID: 6446996
Sorry for lately accept!
8)

Thanks u much,
drvannacult
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now