Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Adding Fields to List Box

Author  Topic 

vk18
Posting Yak Master

146 Posts

Posted - 2006-11-22 : 15:14:09
Hi Friends,

I am trying to add below two fields(description,ckext) in a list box. I am getting error.Can some one help me what i am doing wrong.
Thx

sql = "SELECT *,CAST(description) + ' - ' + ckext as ListBox FROM tblsub"

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-22 : 15:16:06
What are you CASTing description as? Is that not already text?

sql = "SELECT description + ' - ' + ckext as ListBox FROM tblsub"


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2006-11-22 : 15:30:28
quote:
Originally posted by vk18

Hi Friends,

I am trying to add below two fields(description,ckext) in a list box. I am getting error.Can some one help me what i am doing wrong.
Thx

sql = "SELECT *,CAST(description) + ' - ' + ckext as ListBox FROM tblsub"





Hi
Description is text and ckext is integer. I tried this but still doesn work. getting the error "object reference not set to instance of object"
Thx
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-22 : 15:32:42
sql = "SELECT description + ' - ' + CONVERT(varchar, ckext) as ListBox FROM tblsub"


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2006-11-22 : 15:52:44
quote:
Originally posted by Peso

sql = "SELECT description + ' - ' + CONVERT(varchar, ckext) as ListBox FROM tblsub"


Peter Larsson
Helsingborg, Sweden



Thanks, It works now
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-22 : 20:16:57
quote:
Originally posted by Peso

sql = "SELECT description + ' - ' + CONVERT(varchar, ckext) as ListBox FROM tblsub"


Peter Larsson
Helsingborg, Sweden


Note that if you dont specify the size, by default it is 30

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-23 : 00:45:17
I think INTEGER is smaller than 30 digits...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-23 : 03:41:15
quote:
Originally posted by Peso

I think INTEGER is smaller than 30 digits...


Peter Larsson
Helsingborg, Sweden

Yes it is. It is just for precaution

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -