dbTalk Databases Forums  

U2 Select list in NET - newby

comp.databases.pick comp.databases.pick


Discuss U2 Select list in NET - newby in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Terry
 
Posts: n/a

Default U2 Select list in NET - newby - 10-01-2006 , 10:06 PM






Hi all,

I am new to U2 so please excuse me while I get my head around this paradigm
shift from conventional RDMS.

I am trying to list a subset of the customer records (eg Accountbalance>500)
The Uniobject NET doco shows examples that read the entire db (in VB)

us1 = UniObjects.OpenSession("localhost",
"ZZZ", "xxxx", "HS.SALES", "uvcs")
Dim sl As UniSelectList = us1.CreateUniSelectList(2)
' open customer file
fl = us1.CreateUniFile("CUSTOMER")
sl.Select(fl)
Dim lLastRecord As Boolean = sl.LastRecordRead
While Not (lLastRecord)
Dim s As String = sl.Next()
Console.WriteLine("Record ID:" + s)
lLastRecord = sl.LastRecordRead
End While
' read select list as string array
sl.ClearList()
sl.Select(fl)
Dim str_array() As String = sl.ReadListAsStringArray()
Dim uSet As UniDataSet = fl.ReadRecords(str_array)
' use for each statement to print the record
Dim item As UniRecord
For Each item In uSet
Console.WriteLine(item.ToString())
Next item

But I want only a limited number of records returned.
In SQL this would be:
Select Surname from Customer where AccountBalance>500

What is the corresponding action in U2?
I thought it would ba a SlectList, but it appears the Selectlist only
accepts a UniFile as a parameter.
Do I use a UniCommand? If so then would someone provide me with an example
of the syntax.

Thanks
Terry



Reply With Quote
  #2  
Old   
alegon
 
Posts: n/a

Default Re: U2 Select list in NET - newby - 10-02-2006 , 10:51 AM






Hi Terry,

I had this problem and thus decided :

1) Using SQL and DataGrid

Dim tableStyle As New DataGridTableStyle
Dim column As New DataGridTextBoxColumn

Dim Uconexao As OleDbConnection = New
OleDbConnection("Provider=IBM.UniOLEDB; Data Source=" &
CmbServidor.Text & ";user id=AGOADM;password=CHG6s58v;")

Dim Ucomando As OleDbCommand = Uconexao.CreateCommand()

Ucomando.CommandText = "SELECT COMANDO from V_VUCL_COMANDO
WHERE USUARIO = '" & Usuario & "' AND COMANDO LIKE '%" & ParteComando &
"%' order by DATA_COMANDO DESC, HORA DESC"

Uconexao.Open()
Dim Ds As New DataSet
Dim DA_Comando As New OleDbDataAdapter(Ucomando)
DA_Comando.Fill(Ds)
Dim VUCL_COMANDO As New DataTable

DA_Comando.Fill(VUCL_COMANDO)

tableStyle.MappingName = VUCL_COMANDO.TableName.ToString

column.MappingName = "COMANDO"
column.HeaderText = "Pilha de Comandos"
column.Width = 780
tableStyle.GridColumnStyles.Add(column)

'exibir os dados da tabela no datagrid
DgComando.TableStyles.Add(tableStyle)
DgComando.DataSource = VUCL_COMANDO

2) Using Unibasic Subroutine :

Comando = "SELECT FILE IF AccountBalance>500"
Account = "Account.Name"

subr = Usecao.CreateUniSubroutine("EXECUT_COMMAND", 3)
subr.SetArg(0, Comando)
subr.SetArg(2, Account)
subr.Call()
ArrayResp = subr.GetArg(1) ' Array with itens selected
UniObjects.CloseSession(Usecao)
UsecaoVUCL = Nothing


att,

Alexandre (from Brazil)


Terry escreveu:

Quote:
Hi all,

I am new to U2 so please excuse me while I get my head around this paradigm
shift from conventional RDMS.

I am trying to list a subset of the customer records (eg Accountbalance>500)
The Uniobject NET doco shows examples that read the entire db (in VB)

us1 = UniObjects.OpenSession("localhost",
"ZZZ", "xxxx", "HS.SALES", "uvcs")
Dim sl As UniSelectList = us1.CreateUniSelectList(2)
' open customer file
fl = us1.CreateUniFile("CUSTOMER")
sl.Select(fl)
Dim lLastRecord As Boolean = sl.LastRecordRead
While Not (lLastRecord)
Dim s As String = sl.Next()
Console.WriteLine("Record ID:" + s)
lLastRecord = sl.LastRecordRead
End While
' read select list as string array
sl.ClearList()
sl.Select(fl)
Dim str_array() As String = sl.ReadListAsStringArray()
Dim uSet As UniDataSet = fl.ReadRecords(str_array)
' use for each statement to print the record
Dim item As UniRecord
For Each item In uSet
Console.WriteLine(item.ToString())
Next item

But I want only a limited number of records returned.
In SQL this would be:
Select Surname from Customer where AccountBalance>500

What is the corresponding action in U2?
I thought it would ba a SlectList, but it appears the Selectlist only
accepts a UniFile as a parameter.
Do I use a UniCommand? If so then would someone provide me with an example
of the syntax.

Thanks
Terry


Reply With Quote
  #3  
Old   
Symeon
 
Posts: n/a

Default Re: U2 Select list in NET - newby - 10-03-2006 , 02:27 AM



The U2 command you want is 'SELECT CUSTOMER WITH ACCOUNT.BALANCE >
"500"'

How to get that select list into .net - well there are as always many
ways. I think the best is to use the unicommand object to execute the
above select e.g. cmd = session.CreateUniCommans("select ...."). By
default the results of this will become select list 0. So you can then
do your ss = session.CreateUniSelectList(0) and use ss.Next to get
each new record id etc. If you need to have multiple sleect lists at
the same time, you add TO select list number to the end of the select
statement e.g. SELECT VOC TO 2 will use select list 2


If you want a fuler example just ask.


Rgds
Symeon.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.