pemurray
asked on
Cannot create dynamic column in datawindow
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('crea te 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
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('crea
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
ASKER
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(),getr ow())
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
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(),getr
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
ASKER
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,curr enttimebuc ket)
pu_time_bucket = time(currenttimebucket)
pu_time_bucket = Relativetime(pu_time_bucke t, 900)
currenttimebucket = string(pu_time_bucket)
next
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,curr
pu_time_bucket = time(currenttimebucket)
pu_time_bucket = Relativetime(pu_time_bucke
currenttimebucket = string(pu_time_bucket)
next
ASKER
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
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
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