On Mon, Jun 27, 2011 at 8:48 AM, Rafael Copquin
<[email protected]> wrote:
> Is it possible to pass a VFP 9 object as a parameter to a SQL Server
> stored procedure?
>
> The idea is something like this:
>
> select mycursor
> scatter name oMyCursor
>
> cCmd = [exec sp_mysp oMyCursor]
>
-----------
Not sure how this help you Rafael but here is the exact same idea, a
data object passed to a SQL class that does the SP. Also is the SP
that reads the values of data and knows if Update or Insert.
Public Shared Function Save(ByVal sl As SysLookup) As Boolean
Dim bResult As Boolean = False
Dim iRowUpdated As Int32
Dim iRetVal As Int32
Try
If sl.isDirty Then
'update the table for this Message, pass in all table fields
Using cmd As New SqlCommand
With cmd
.CommandText = "dbo.spSysLookupInsertUpdate"
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@lookupType",
SqlDbType.Int).Value = sl.LookupType
.Parameters.Add("@Description",
SqlDbType.VarChar, 20).Value = sl.Description
.Parameters.Add("@lookupid",
SqlDbType.Int).Value = sl.LookupID
iRowUpdated = DataLayer.ExecProdNonQuery(cmd)
'Int32.TryParse(.Parameters("@RetVal").Value.ToString, iRetVal)
If iRowUpdated <> 0 Then
sl.isDirty = False
If iRetVal = 1 Then
bResult = True
End If
<SPROC Code here>
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create proc [dbo].[spSysLookupInsertUpdate]
@lookupType int =0
, @description varchar(50)
, @lookupid int =0
as
if @lookupid = 0
begin
if @lookuptype >0
begin
INSERT INTO [uhs_prod].[dbo].[SysLookups]
([LookupType]
,[Description])
VALUES
(@lookupType, @Description)
end
end
else
begin
update syslookups
set [Description] = @description
where lookupid = @lookupid
end
End If
End With
End Using
End If
Catch ex As Exception
Debug.Assert(False)
Throw
End Try
Return bResult
End Function
--
Stephen Russell
Unified Health Services
60 Germantown Court
Suite 220
Cordova, TN 38018
Telephone: 888.510.2667
901.246-0159 cell
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.