Solved

Plz help a newbie!

Posted on 2001-08-29
10
334 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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
 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
System.out.println to console instead to Jboss log file 12 686
Doxygen plugin for Android Studio 1 552
Should CArray be used for a list of pointers in C++? 19 102
Angular JS Route 3 68
In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

813 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

10 Experts available now in Live!

Get 1:1 Help Now