"Incorrect syntax near" problems

G

Guest

Hi Everyone,
I'm having a slight problem, I hope I didn't overlook something. I'm getting
the following error when I try to execute the function below:
Incorrect syntax near 'intake_GetListSet'."

Private sub LoadListSet()
dim da as New SqlDataAdapter
Dim cmd as New SqlCommand
try
cmd.Connection = OpenConnection()
cmd.CommandType = CommandType.Text
cmd.CommandText = "intake_GetListSet"
cmd.Parameters.Add("@PatientId",SqlDbType.VarChar , 20).Value = fPatientId
da.SelectCommand = cmd
ListSet.Clear
da.Fill(ListSet) >>>> Errors here.
Catch ex As Exception
msgbox(ex.Message )
finally
cmd.Connection.Dispose
da.Dispose
End Try
End Sub
The Stored proc follows.

CREATE PROCEDURE [dbo].[intake_GetListSet]
@PatientId varchar(20)
AS

SELECT List.KeyId, List.PatientId, List.ExamId, List.TypeId,
ListTypes.TypeName, List.ListType
FROM (PhysicalExamination LEFT JOIN Medeator
ON PhysicalExamination.KeyId = Medeator.ExamId)
LEFT JOIN (List LEFT JOIN ListTypes ON List.TypeId = ListTypes.TypeId) ON
Medeator.ForeignKeyId = List.KeyId
Where List.PatientId = @PatientId
GO

In SQL Enterprise Manager the stored proc works just fine. It only seens to
error in the code above. fPatientId does have a valid value. Does anyone have
an idea whats going on. Thanks for any help.
Michael
 
K

Ken Tucker [MVP]

Hi,

You are calling a stored procedure so your command type is stored
procedure.

cmd.CommandType = CommandType.StoredProcedure

Ken
 
C

Chris

Michael said:
Hi Everyone,
I'm having a slight problem, I hope I didn't overlook something. I'm getting
the following error when I try to execute the function below:
Incorrect syntax near 'intake_GetListSet'."

Private sub LoadListSet()
dim da as New SqlDataAdapter
Dim cmd as New SqlCommand
try
cmd.Connection = OpenConnection()
cmd.CommandType = CommandType.Text
cmd.CommandText = "intake_GetListSet"
cmd.Parameters.Add("@PatientId",SqlDbType.VarChar , 20).Value = fPatientId
da.SelectCommand = cmd
ListSet.Clear
da.Fill(ListSet) >>>> Errors here.
Catch ex As Exception
msgbox(ex.Message )
finally
cmd.Connection.Dispose
da.Dispose
End Try
End Sub
The Stored proc follows.

CREATE PROCEDURE [dbo].[intake_GetListSet]
@PatientId varchar(20)
AS

SELECT List.KeyId, List.PatientId, List.ExamId, List.TypeId,
ListTypes.TypeName, List.ListType
FROM (PhysicalExamination LEFT JOIN Medeator
ON PhysicalExamination.KeyId = Medeator.ExamId)
LEFT JOIN (List LEFT JOIN ListTypes ON List.TypeId = ListTypes.TypeId) ON
Medeator.ForeignKeyId = List.KeyId
Where List.PatientId = @PatientId
GO

In SQL Enterprise Manager the stored proc works just fine. It only seens to
error in the code above. fPatientId does have a valid value. Does anyone have
an idea whats going on. Thanks for any help.
Michael

Yes you overlooked something simple....

cmd.CommandType = CommandType.Text

Should be:

cmd.CommandType = CommandType.StoredProcedure

Have a good one...
Chris
 
G

Guest

Hi Chris,
Just shoot me now. My gosh, how could I have missed that. Sorry about that
you all.
Thanks again.
Michael


Chris said:
Michael said:
Hi Everyone,
I'm having a slight problem, I hope I didn't overlook something. I'm getting
the following error when I try to execute the function below:
Incorrect syntax near 'intake_GetListSet'."

Private sub LoadListSet()
dim da as New SqlDataAdapter
Dim cmd as New SqlCommand
try
cmd.Connection = OpenConnection()
cmd.CommandType = CommandType.Text
cmd.CommandText = "intake_GetListSet"
cmd.Parameters.Add("@PatientId",SqlDbType.VarChar , 20).Value = fPatientId
da.SelectCommand = cmd
ListSet.Clear
da.Fill(ListSet) >>>> Errors here.
Catch ex As Exception
msgbox(ex.Message )
finally
cmd.Connection.Dispose
da.Dispose
End Try
End Sub
The Stored proc follows.

CREATE PROCEDURE [dbo].[intake_GetListSet]
@PatientId varchar(20)
AS

SELECT List.KeyId, List.PatientId, List.ExamId, List.TypeId,
ListTypes.TypeName, List.ListType
FROM (PhysicalExamination LEFT JOIN Medeator
ON PhysicalExamination.KeyId = Medeator.ExamId)
LEFT JOIN (List LEFT JOIN ListTypes ON List.TypeId = ListTypes.TypeId) ON
Medeator.ForeignKeyId = List.KeyId
Where List.PatientId = @PatientId
GO

In SQL Enterprise Manager the stored proc works just fine. It only seens to
error in the code above. fPatientId does have a valid value. Does anyone have
an idea whats going on. Thanks for any help.
Michael

Yes you overlooked something simple....

cmd.CommandType = CommandType.Text

Should be:

cmd.CommandType = CommandType.StoredProcedure

Have a good one...
Chris
 
Top