How to input sql server 2005 stored procedures @parameters into insert statement using c# visual studio

sql server 2005 , visual studio 2005 Belfast, United Kingdom
  • 8 years ago
    THis is My SP USE [PostBook] GO /****** Object: StoredProcedure [dbo].[CreateNewPost] Script Date: 01/17/2009 15:36:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Mark Stewart -- Create date: 09/10/2008 -- Description: New Post Item -- ============================================= ALTER PROCEDURE [dbo].[CreateNewPost] -- Add the parameters for the stored procedure here --@DateReceived smalldatetime , @PostFrom varchar(200), @PostTo varchar(200), @CorrespondenceDate smalldatetime, @DateForwarded smalldatetime, @ResponseDate smalldatetime, @Summary varchar(max), @Disposal varchar(max), @DisposalDate smalldatetime, @ReferredTo varchar (200), @AckDate smalldatetime, @AckBy varchar (200), @InterimReply varchar (200), @InterimDate smalldatetime, @ReplyDate smalldatetime, @BusinessArea varchar (200), @UserID int, @ClassID int AS DECLARE @i AS INT BEGIN TRANSACTION SELECT @i = COALESCE(MAX(ReferenceID), 0) FROM dbo.PostBookItems WITH (TABLOCKX, HOLDLOCK) WHERE PostBookID = 1 INSERT INTO dbo.PostBookItems(PostBookID, ReferenceID, DateReceived, PostFrom, PostTo, CorrespondenceDate, DateForwarded, ResponseDate, Summary, Disposal, DisposalDate, ReferredTo, AckDate, AckBy, InterimReply, InterimDate, ReplyDate, BusinessArea,ClassID,UserID,DateUpdated) VALUES(1, @i + 1, GETDATE(), @PostFrom, @PostTo, @CorrespondenceDate, @DateForwarded, @ResponseDate, @Summary, @Disposal, @DisposalDate, @ReferredTo, @AckDate, @AckBy, @InterimReply, @InterimDate, @ReplyDate, @BusinessArea,@ClassID,@UserID,GETDATE()) COMMIT And this is my windows form code:- private void saveNewPostItemMenuStrip_Click(object sender, EventArgs e) { dtPostBookItemsBindingSource.EndEdit(); taPostBookItems.CreateNewPost(dsMain.dtPostBookItems,, Program.PostbookID,(Convert.ToInt32(postFromTextBox.Text.ToString) (Convert.ToString(postToTextBox.Text.ToString) correspondenceDateDateTimePicker.Value.ToShortTimeString) dateForwardedDateTimePicker.Value.ToShortTimeString), responseDateDateTimePicker.Value, summaryTextBox.ToString, disposedTextBox.ToString, disposalNotesTextBox.ToString, ValueType = Convert.ToDateTime(disposalDateDateTimePicker.Value)) referredToTextBox.ToString, ackDateDateTimePicker.Value, ackByTextBox.ToString, interimReplyTextBox.ToString, interimDateDateTimePicker.Value, replyDateDateTimePicker.Value, businessAreaTextBox.ToString, classIDTextBox))); Help please.

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook