SQL connection

G

Guest

I have a quick connection from a newbie.
I am trying to run a stored procedure but I get the following error:
Could not find stored procedure. I know it is there so what am I doing
wrong? Thank you in advance.
My code is as follows:
Dim cn As SqlClient.SqlConnection
Dim cmd As SqlClient.SqlCommand
cn = New SqlClient.SqlConnection("Server=******; Database=*****;
uid=****; pwd=******")
cn.Open()
If cn.State = ConnectionState.Open Then
cmd = New SqlClient.SqlCommand("CreelScheduleInfo1")
cmd.Connection = cn
cmd.CommandType = CommandType.StoredProcedure
Dim p As New SqlClient.SqlParameter("@LakeCode",
SqlDbType.VarChar, 50, "115")
p.Value = True
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
cn.Close()
End If
 
G

Guest

Is it a SQL server namespace issue...? Is your procedure created in a
namespace other than the dbo namespace, if so specify it as such in your
command constructor("myuser.stored_proc")... You should always qualify the
namespace even if it is dbo.
 
K

Ken Tucker [MVP]

Hi,

Open up the database in vs.net's server explorer and make the stored
procedure exists. I would also make sure you have the parameter names
correct.

Ken
-----------------------
I have a quick connection from a newbie.
I am trying to run a stored procedure but I get the following error:
Could not find stored procedure. I know it is there so what am I doing
wrong? Thank you in advance.
My code is as follows:
Dim cn As SqlClient.SqlConnection
Dim cmd As SqlClient.SqlCommand
cn = New SqlClient.SqlConnection("Server=******; Database=*****;
uid=****; pwd=******")
cn.Open()
If cn.State = ConnectionState.Open Then
cmd = New SqlClient.SqlCommand("CreelScheduleInfo1")
cmd.Connection = cn
cmd.CommandType = CommandType.StoredProcedure
Dim p As New SqlClient.SqlParameter("@LakeCode",
SqlDbType.VarChar, 50, "115")
p.Value = True
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
cn.Close()
End If
 
G

Guest

Your suggestion seemed to help but another error has occurred. I know get a
"Could not connect to server 'GOFISH' because 'dstrick' is not defined as a
remote login at the server." Thanks for your help. Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top