sql server
-
USE [lib] GO /****** Object: Table [dbo].[AUTHER] Script Date: 7/17/2020 7:55:40 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[AUTHER]( [AUTHER_ID] [int] IDENTITY(1,1) NOT NULL, [AUTHER_NAME] [nvarchar](50) NULL, CONSTRAINT [PK_AUTHER] PRIMARY KEY CLUSTERED ( [AUTHER_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO USE [lib] GO /****** Object: Table [dbo].[DOC] Script Date: 7/17/2020 7:56:12 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[DOC]( [DOC_ID] [int] IDENTITY(1,1) NOT NULL, [DOC_NAME] [nvarchar](50) NULL, [AUTHER_ID] [int] NULL, [DOC_PATH] [nvarchar](50) NOT NULL, [DOC_DATE] [date] NULL, CONSTRAINT [PK_DOC] PRIMARY KEY CLUSTERED ( [DOC_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[DOC] WITH CHECK ADD CONSTRAINT [FK_DOC_AUTHER] FOREIGN KEY([AUTHER_ID]) REFERENCES [dbo].[AUTHER] ([AUTHER_ID]) GO ALTER TABLE [dbo].[DOC] CHECK CONSTRAINT [FK_DOC_AUTHER] GO
אולי צריך להגדיר בפרוצדורה RETURN?
-
@OdedDvir אמר בsql server:
ExecuteScalar
זה הקוד של השליחה לפונקציה ושיניתי כאמור כפי שכתבתם רק עכשיו זה מתריע לי שהפונקיה מחזירה OBJECTולא INT
public int InsertDoc( string docName, string autherName, string docPath, DateTime docDate) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("lib`"))) { List<Doc> doc = new List<Doc>(); doc.Add(new Doc { DocName = docName , autherName = autherName, DocPath = docPath , DocDate = docDate }); return connection.ExecuteScalar("dbo.INSERT_DOC @docName, @autherName, @docPath, @docDate", doc); } }