VB.NET - Could not find stored procedure 'False'

Asked By Apurba D on 03-Nov-05 03:47 PM
I am designing this web page in vb.net (asp.net) and SQL server 2000 and I am ahving a weird prob. 
A section fo the code is like : cmd.CommandText = "SELECT shop_name from shop_profile where shop_id &' " = dl_Shop_Id.SelectedItem.Text & "" but this code gives the follwing error msg:
Could not find stored procedure 'False'
Whereas if I put some value manually to test the code like , cmd.CommandText = "SELECT shop_name from shop_profile where shop_id = 3" it works perfectly .. Any idea why ....

Command Text

Asked By F Cali on 03-Nov-05 04:08 PM
Hi Apurba,
Your command text should look like as follows (it's a little bit hard to understand from your post):
cmd.CommandText = "SELECT shop_name from shop_profile where shop_id = " & dl_Shop_Id.SelectedItem.Text
Hope this helps.

maybe

Asked By Jason Cook on 03-Nov-05 04:09 PM
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT shop_name FROM shop_profile WHERE shop_id = '" & dl_Shop_Id.SelectedItem.Text & "'"
Looks like a little bit of a syntax error, but maybe just a typo. I would try putting a watch on the dl_Shop_Id.SelectedItem.Text and see if it holds the right parameter. In my opinion you should use stored procedures, as SQLServer makes a server-side execution plan for the stored procedure, when you use T-SQL the server has to make an execution plan every time you run a T-SQL script. Try
CREATE PROCEDURE sp_FindShopName
(
    @shop_id int
)
AS
SELECT shop_name
FROM shop_profile 
WHERE shop_id = @shop_id
now in VB we would need to do this to use that stored procedure
...
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_FindShopName"
Dim parameter as SqlParameter = New SqlParameter("@shop_id", Convert.ToInt32(dl_Shop_Id.SelectedItem.Text))
parameter.Direction = ParameterDirection.Input
parameter.DbType = DbType.Int32
cmd.Parameters.Add(parameter)
'I'm going out on a limb and assuming you are using a data adapter
dataAdapter.SelectCommand = cmd
...

CommandText

Asked By Aarthi Saravanakumar on 03-Nov-05 04:13 PM
should look like
cmd.CommandText = "SELECT shop_name from shop_profile where shop_id =' " &  dl_Shop_Id.SelectedItem.Text & "'"
as the
Asked By Venkat K on 03-Nov-05 09:32 PM
error message you typed, i have small doubt may be the sp_ is the keyword that uses for help in sql server, and so for that reason it gives error
Try to make change to you stored procedure and try to run, there is nothing wrong in your procedure, but slight change 
"select shop_name from shop_profile where shop_id=" & CInt(dll_Shop_id.SelectedItem.Text)
Modified Query
Asked By Sunitha Nambari on 03-Nov-05 11:06 PM
hi,
Try this:
There is an error in your query:
 "Select * from shop_profile Where shop_id='" & dl_Shop_id.SelectedItem.Text & "'"
Regards,
Suneetha
Thanks
Asked By Apurba D on 04-Nov-05 02:09 PM
Thanks you all guyz .. all of your inputs helped a lot and I have fixed the prob now... This was my second post in this forum and .. I have the feeling that I will have a very good time with all you pros....Thnx again...