Solved

Cannot create dynamic column in datawindow

Posted on 2006-06-18
7
4,848 Views
Last Modified: 2013-12-26
Hello Everyone,

I am trying to create a new column in a datawindow, but it doesn't seem to work.

There are no errors (that I see).

Here is my code:

*****
//dw_1.Modify("create column(1)")
dw_1.Modify("create column(band=detail id=1 name=1)")
//dw_original.modify('create column(name=new_column visible="1" band=detail id=' + s_id + ' x=.........')
dw_1.modify('create column(name=1 visible="1" band=detail')


dw_1.Modify("create column(2)")
dw_1.Modify("create column(3)")
dw_1.Modify("create column(4)")
dw_1.Modify("create column(5)")
dw_1.Modify("create column(6)")
*****

It runs, I pull up the datawindow, but I don't see the column.

Thanks!!!

PEM
0
Comment
Question by:pemurray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 18

Assisted Solution

by:diasroshan
diasroshan earned 250 total points
ID: 16957385
Hi,

i dont think u can add columns using modify... there are various ways to achieve what u want... i mean, i need to know exactly what u want to do... what i understand is u want to create a dynamic DW...

just check this PB example from the Help...

string error_syntaxfromSQL, error_create
string new_sql, new_syntax

new_sql = 'SELECT emp_data.emp_id, ' &
        + 'emp_data.emp_name ' &
        + 'from emp_data ' &
        + 'WHERE emp_data.emp_salary>45000'

new_syntax = SQLCA.SyntaxFromSQL(new_sql, &
        'Style(Type=Grid)', error_syntaxfromSQL)

IF Len(error_syntaxfromSQL) > 0 THEN
        // Display errors
        mle_sfs.Text = error_syntaxfromSQL
ELSE
        // Generate new DataWindow
        dw_new.Create(new_syntax, error_create)
        IF Len(error_create) > 0 THEN
            mle_create.Text = error_create
        END IF
END IF

dw_new.SetTransObject(SQLCA)
dw_new.Retrieve()

//Check the above example and tell me what u want exactly... will help u achieve what u want...

Cheers,
Rosh
0
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 250 total points
ID: 16959648
hi,

Are you creating datawindow dynamically or creating in column dynamically in existing datawindow ?

If datawindow is already there and all required columns are selected in it's syntax but not painted in datawindow, then what you need is Modify function. And best is first place one column in datawindow and designtime, check the datasource of that datawindow, copy the syntax of that column, remove column from datawindow and use modify function runtime to create column.

e.g.

dw_1.Modify('create column(band=detail id=1 alignment="0" tabsequence=32766 border="0" color="0" x="17595" y="36" height="76" width="512" format="[general]" html.valueishtml="0"  name=trans_no visible="0" edit.limit=0 edit.case=any edit.autoselect=yes edit.imemode=0  font.face="Arial" font.height="-12" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="12632256" )')

here in this syntax id is important it refers to the actual column that you have selected in your query.

Regards,
Sandeep
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 16959776
Hi,

also to see column in datawindow following properties are more importance

width, height, band, x, y, border, background.color, color

also check return value when you call modify funciton

ll_return  = dw_1.modify('.......')
Messagebox('',ll_return)

Regards,
Sandeep
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pemurray
ID: 16960591
To: Diasroshan

Unfortunately, the data does not exist in the database the way that I need it and I do not think it is possible to use SyntaxFromSQL.  I have to many functions that loop through all of the tables and do special logic.

Sandeep,

Thanks for your note.  I think this is arduous, but I understand where you are headed.  Can I put that code in a for next loop and add the columns interatively?  Or do I have to assembe one giant string and then write it out once?

I will try adding your code into a for next loop for now as I want to work with smaller chuncks of the string.

Thank you, gentlemen.

Paul
0
 

Author Comment

by:pemurray
ID: 16969959
All,

Okay, here is what I have and what I did.

I created a datawindows with one column.

I deleted the column.

I added 48 computed columns.

Ideally, I would simply make the expression in the each of the computed columns: gridarray(getcolumn(),getrow())

Then I would be done.  But I cannot figure out how to do that so now I am trying to add columns dynamically with the values in my array.

Sandeep, I added your code and ran the program.  I put in a messagebox to see the string that dwModify returned.  The string was null.

Then I looked at the datawindow, but I did not see any NEW columns.  I am perplexed.

Here is the code:

STRING SANDEEP
SANDEEP = dw_1.Modify('create column(band=detail id=1 alignment="0" tabsequence=32766 border="0" color="0" x="17595" y="36" height="76" width="512" format="[general]" html.valueishtml="0"  name=trans_no visible="0" edit.limit=0 edit.case=any edit.autoselect=yes edit.imemode=0  font.face="Arial" font.height="-12" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="12632256" )')

messagebox("Sandeep Response",SANDEEP)

Again, the messagebox popped up, but did not display anything.

Also, if I AM successful in creating a dynamic column which property do use to define the NAME of the column?  I added name="NewColumn"

Thanks for all of your help.

Paul


0
 

Author Comment

by:pemurray
ID: 16970153
ONE MORE THING...

When I create the column, I want to automatically increment the column name or id (whichever one it is that I will need to refer to it later.

So if I need to create 20 columns, I want them to be named/numbered/id'd 1 through 20 so I can REFER to it and do the following later:

***CHANGE THE NAME OF EACH COLUMN

string dwmodreturncode
for i = 1 to countyarraylength
      
      dw_mod_string = 'Object.' + "t" + string(i) + ".Text=" +"'"+ countyarray[i] + "'"
      dwmodreturncode = dw_1.modify(dw_mod_string)

next

***INSERT NEW ROWS AND CHANGE THE VALUE OF EACH ROW IN EACH COLUMN
***IN THE CODE BELOW, I JUST WANT TO WRITE OUT THE TIME (E.G., 14:15:00) IN THE FIRST COLUMN

//NOW INSERT THE ROWS INTO DW_1 - 48 rows = 12 hours

for i = 1 to 48
      newrow = dw_1.insertrow(0)
      setitemresult = dw_1.setitem(newrow,1,currenttimebucket)
      pu_time_bucket = time(currenttimebucket)
      pu_time_bucket = Relativetime(pu_time_bucket, 900)
      currenttimebucket = string(pu_time_bucket)
next
0
 

Author Comment

by:pemurray
ID: 16970969
Gentlemen,

I am closing this out.

I came across Bhatti's suggestion to use an External Datawindow in grid format that allows you to simply make invisible the fields that you don't want.

I am hoping that I won't run into any roadblocks, but I have already tried it out a bit and it seems to be a clean way to do it.

Both of your answers could work, so I am splitting the points.

Thank you,

Paul
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 and create keystrokes in Netbeans IDE 8.0 for Windows.

691 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