I have started to learn SQL for some stuff I am doing at work. I tryed a number of queries that I wrote using a sample database loaded on our server and all but one have been successful but I can't find teh problem with the one that doesn't work.
When tested in the Query Tool with Enterprise Manager it pulls back the correct 12 records but once I try it within some VB code it runs but fails to pull out any records.
The select statement I am using is :-
select SkillCode from Skill where DATALENGTH(Convert(varchar(4),SkillCode)) <=3 order by SkillCode ASC
The VB Code :-
cn.CursorDriver = rdUseOdbc
cn.Connect = "Driver={SQL Server};Server=RMSC001;UID=sa;PWD=sa;Database=sqlclass;"
cn.EstablishConnection
qy.SQL = "select SkillCode from Skill where DATALENGTH(Convert(varchar(4),SkillCode)) <=3 order by SkillCode ASC"
qy.RowsetSize = 1
Set qy.ActiveConnection = cn
Set Rs = qy.OpenResultset(rdOpenKeyset, rdConcurRowVer)
The same chuck of code has worked on the other 4 so I am assuming that the select statement is incorrect in some way but the fact that it works in Enterprise Manager Query Tool but not in VB has thrown me!!!
Can anyone spot any reason why this wouldn't work within VB code?
Enter your message below
Sign in or Join us (it's free).