Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query writing Error in VB 1

Status
Not open for further replies.

oops4me

Programmer
Jul 7, 2003
50
IN
Hello,
I have written following query in Vb
dim str11 as string

str11="select case a.Company_id when 0 then '' Else: a.Comp_name end , case b.Desig_id when 0 then '' Else: b.Desig_name end , case c.Industry_id when 0 then '' Else: c.Ind_name end , case d.Function_id when 0 then '' Else: d.Function_name end from Company_Mst a,Designation_Mst b,Industry_Mst c, Function_Mst d Where a.Company_id = " & rs4.Fields("Company_id") & " And b.Desig_id =" & rs4.Fields("Desig_id") & " And c.Industry_id =" & rs4.Fields("Indusrty_id") & " And d.Function_id =" & rs4.Fields("Function_id")

after this i ve written
set rs2=con.execute(str11)

but it is giving me error at str11 where i am assigning query to string str11
as "Item can not found in collection corresponding to requested name or ordinal "
still i ve not executed the query.

i ve written following to check query contents

msgbox(str11="select case a.Company_id when 0 then '' Else: a.Comp_name end , case b.Desig_id when 0 then '' Else: b.Desig_name end , case c.Industry_id when 0 then '' Else: c.Ind_name end , case d.Function_id when 0 then '' Else: d.Function_name end from Company_Mst a,Designation_Mst b,Industry_Mst c, Function_Mst d Where a.Company_id = " & rs4.Fields("Company_id") & " And b.Desig_id =" & rs4.Fields("Desig_id") & " And c.Industry_id =" & rs4.Fields("Indusrty_id") & " And d.Function_id =" & rs4.Fields("Function_id"))

then also it is giving me same error.
can any body tell me what is the problem & it's solution. If i run this query at
sql server it is working fine.
please help me.
Edit/Delete Message
 
It might be a typo but is
Code:
rs4.Fields("Indusrty_id")
meant to be
Code:
rs4.Fields("Industry_id")
as this may casue your problem.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
You're welcome, thanks for the star [smile]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
A typo in a post about a typo [smile]

I noticed when I posted it but I was hopimg no-one else would...[wink]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
And if you look closely I've made another in that reply [blush]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
And not just any old typo, but the exact same kind as in the code.

<And if you look closely I've made another in that reply

Hopimg your wishes are met,

Bob

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top