This is a migrated thread and some comments may be shown as answers.

Column Names and Types?

1 Answer 66 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
julian Welby Everard
Top achievements
Rank 1
julian Welby Everard asked on 21 Oct 2010, 09:24 AM
Hi

How do I get the column names from a quiery result set (IQueryResult)

We use stored procedures to return the data, I know it must be posiable as the grid controls return the columns names, but I need to access this information before i deploy it to the grid.

Public Shared Function GetListData(ByVal scope As IObjectScope, ByVal listID As Guid) As IQueryResult
    Dim query As IQuery = scope.GetSqlQuery("prGetList ?", Nothing, "GUID ContactID")
    Dim res As IQueryResult = query.Execute(New Object() {contactID})
    Dim count As Integer = res.Count 'executes the query
    Return res
End Function

the code is the processed in the normal way....

Dim result As IQueryResult = DBLibrary.StoredProcedure.GetListData(scope, guidListID)
For Each pr As Object() In result
      
    ....... = Convert.ToInt32(pr(0))
  
Next
scope.Dispose()

but at the point of extracting the information for column 0, 1, 2 etc I would like to know the column name, as the data needs to be passed back as XML in the format <Column Name='someColumn' value='someValue' type='system.string' /> etc

the column names may change depending on the list id supplied. the code does return data, but i cant find the column name anywhere

any got any ideas

Thanks

Jules 

1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 27 Oct 2010, 08:10 AM
Hello julian Welby Everard,

Unfortunately we do not have an API that extracts column names when a result set is returned from a stored procedure. The result set is a collection of object arrays and each object array has a corresponding value for the columns specified in the SELECT clause in the stored procedure. Can you elaborate a bit more on the binding you specify for the grid and what type of project you are developing (a web site as you have marked in the Ticket Info)? If you know that through the stored procedure a collection of persistent types is returned you can benefit from working with the Query<T> and QueryResultList<T> classes to get a strongly typed result set. Then you can simply use the names of the properties of the persistent type.

I am looking forward to your reply. 

Sincerely yours,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
julian Welby Everard
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or