Stored Procedure troublehttp://forums.asp.net/t/1788863.aspx/1?Stored+Procedure+troubleMon, 09 Apr 2012 14:30:08 -040017888634914869http://forums.asp.net/p/1788863/4914869.aspx/1?Stored+Procedure+troubleStored Procedure trouble <p>Hi everyone,<br> I have an existing website that uses a stored procedure that I am trying to add additional fields to each record. &nbsp;This is as far as I've gotten before getting a &nbsp;&quot;Procedure or function 'sp_D21ToDoInsert' expects parameter '@Priority', which was not supplied.&quot; Thank you for your help in advance.&nbsp;</p> <p></p> <p>Page code:</p> <pre class="prettyprint">&lt;%@ Page Language=&quot;VB&quot; Debug=&quot;true&quot;%&gt; &lt;script runat=&quot;server&quot;&gt; Dim BaseID as Integer Dim Usersaveable as Boolean Sub Page_Load(Sender as Object,e as EventArgs) ButtonRollovers(btnAdd) ButtonRollovers(btnSave) ' user rights check If Global.ASP.Global.RoleCheck(User.Identity.Name,1) OR Global.ASP.Global.RoleCheck(User.Identity.Name,2) UserSaveable = True Else UserSaveable = False End If If Not page.IsPostBack RefreshGrid() Hidedetails() If Usersaveable btnAdd.visible = true Else btnAdd.Visible = false End If End If End Sub Sub HideDetails() tbNote.Visible = False tbPriority.Visible = False tbDateAdded.Visible = False tbDateCompleted.Visible = False lbNote.Visible = False lbPriority.Visible = False lbDateAdded.Visible = False lbDateCompleted.Visible = False btnsave.visible = false If UserSaveable btnAdd.Visible = True End If End Sub Sub RefreshGrid() dgResults.Datasource = Global.ASP.Global.SQLSelect(&quot;SELECT * FROM D21ToDoNotes&quot;) dgResults.Databind() End Sub Sub dgResults_ItemCreated(sender As Object, e As DataGridItemEventArgs) Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem e.Item.Attributes.Add(&quot;onmouseover&quot;, &quot;this.style.backgroundColor = 'sandybrown'&quot;) e.Item.Attributes.Add(&quot;onmouseout&quot;, &quot;this.style.backgroundColor = 'peachpuff'&quot;) Dim myButton As Button = CType(e.Item.Cells(5).Controls(0), Button) myButton.CssClass = &quot;button_Grid&quot; buttonrollovers(MyButton) End Select End Sub Sub ButtonRollovers(buttonname as object) Buttonname.Attributes.Add(&quot;onmouseover&quot;, &quot;this.style.backgroundColor = '#33CCFF'&quot;) Buttonname.Attributes.Add(&quot;onmouseout&quot;, &quot;this.style.backgroundColor = '#5777AD'&quot;) End Sub Sub btnAdd_Click(sender As Object, e As EventArgs) btnAdd.visible = false btnsave.Visible = True tbNote.Visible = True tbPriority.Visible = True tbDateAdded.Visible = True tbDateCompleted.Visible = True lbNote.Visible = True lbNote.Text = &quot;To Do Note:&quot; lbPriority.Visible = True lbPriority.Text = &quot;Priority (1 Hi to 5 Low): &quot; lbDateAdded.Visible = True lbDateAdded.Text = &quot;Date Added: &quot; lbDateCompleted.Visible = True lbDateCompleted.Text = &quot;Date Completed: &quot; End Sub Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Global.ASP.Global.SQLSingle(&quot;sp_D21ToDoInsert '&quot; &amp; tbNote.Text &amp; &quot;,&quot; &amp; tbPriority.Text &amp; &quot;,&quot; &amp; tbDateAdded.Text &amp; &quot;,&quot; &amp; tbDateCompleted.Text &amp; &quot;'&quot;) RefreshGrid() HideDetails() End Sub Sub dgResults_ItemCommand(sender As Object, e As DataGridCommandEventArgs) If e.commandname = &quot;Delete&quot; Dim DeleteSQL as String DeleteSQL = &quot;DELETE FROM D21ToDoNotes WHERE D21ToDoNoteID =&quot; &amp; e.Item.Cells(0).Text Global.ASP.Global.SQLInsert(DeleteSQL) RefreshGrid() HideDetails() End If End Sub &lt;/script&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;MINA Base Information Monaco Information Network Application&lt;/title&gt; &lt;!--#include file=&quot;include4aspx.htm&quot;--&gt; &lt;link href=&quot;favicon.ico&quot; rel=&quot;shortcut icon&quot; /&gt; &lt;/head&gt; &lt;body&gt; &lt;form runat=&quot;server&quot;&gt; &lt;div align=&quot;center&quot;&gt; &lt;/div&gt; &lt;div align=&quot;center&quot;&gt; &lt;asp:DataGrid id=&quot;dgResults&quot; runat=&quot;server&quot; BackColor=&quot;#FFE0C0&quot; Font-Names=&quot;Arial&quot; Font-Size=&quot;X-Small&quot; Width=&quot;80%&quot; AutoGenerateColumns=&quot;False&quot; OnItemCreated=&quot;dgResults_ItemCreated&quot; OnItemCommand=&quot;dgResults_ItemCommand&quot;&gt; &lt;HeaderStyle backcolor=&quot;#FF8000&quot;&gt;&lt;/HeaderStyle&gt; &lt;Columns&gt; &lt;asp:BoundColumn Visible=&quot;False&quot; DataField=&quot;D21ToDoNoteID&quot; ReadOnly=&quot;True&quot; HeaderText=&quot;ToDoID&quot;&gt;&lt;/asp:BoundColumn&gt; &lt;asp:BoundColumn DataField=&quot;ToDoNote&quot; HeaderText=&quot;Notes&quot;&gt;&lt;HeaderStyle width=&quot;60%&quot;&gt;&lt;/HeaderStyle&gt;&lt;/asp:BoundColumn&gt; &lt;asp:BoundColumn DataField=&quot;Priority&quot; HeaderText=&quot;Priority (1 Hi to 5 Low)&quot;&gt;&lt;HeaderStyle Width=&quot;10%&quot; /&gt;&lt;/asp:BoundColumn&gt; &lt;asp:BoundColumn DataField=&quot;DateAdded&quot; HeaderText=&quot;Date Added&quot;&gt;&lt;HeaderStyle Width=&quot;10%&quot; /&gt;&lt;/asp:BoundColumn&gt; &lt;asp:BoundColumn DataField=&quot;DateCompleted&quot; HeaderText=&quot;Date Completed&quot;&gt;&lt;HeaderStyle Width=&quot;10%&quot; /&gt;&lt;/asp:BoundColumn&gt; &lt;asp:ButtonColumn Text=&quot;Delete&quot; ButtonType=&quot;PushButton&quot; HeaderText=&quot;Delete Note&quot; CommandName=&quot;Delete&quot;&gt;&lt;HeaderStyle Width=&quot;10%&quot; /&gt;&lt;/asp:ButtonColumn&gt; &lt;/Columns&gt; &lt;/asp:DataGrid&gt; &lt;/div&gt; &lt;p align=&quot;center&quot;&gt; &lt;asp:Button class=&quot;button_long&quot; id=&quot;btnAdd&quot; onclick=&quot;btnAdd_Click&quot; runat=&quot;server&quot; Text=&quot;Add Note&quot;&gt;&lt;/asp:Button&gt; &lt;/p&gt; &lt;!-- Insert content here --&gt; &lt;p align=&quot;center&quot;&gt; &amp;nbsp;&lt;asp:Label ID=&quot;lbNote&quot; runat=&quot;server&quot;&gt;&lt;/asp:Label&gt;&lt;/br&gt;&lt;asp:TextBox id=&quot;tbNote&quot; runat=&quot;server&quot; Width=&quot;619px&quot; Height=&quot;99px&quot; TextMode=&quot;MultiLine&quot;&gt;&lt;/asp:TextBox&gt;&lt;/br&gt; &amp;nbsp;&lt;asp:Label ID=&quot;lbPriority&quot; runat=&quot;server&quot;&gt;&lt;/asp:Label&gt;&lt;asp:TextBox ID=&quot;tbPriority&quot; runat=&quot;server&quot; TextMode=&quot;SingleLine&quot;&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID=&quot;lbDateAdded&quot; runat=&quot;server&quot;&gt;&lt;/asp:Label&gt;&lt;asp:TextBox ID=&quot;tbDateAdded&quot; runat=&quot;server&quot; TextMode=&quot;SingleLine&quot;&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID=&quot;lbDateCompleted&quot; runat=&quot;server&quot;&gt;&lt;/asp:Label&gt;&lt;asp:TextBox ID=&quot;tbDateCompleted&quot; runat=&quot;server&quot; TextMode=&quot;SingleLine&quot;&gt;&lt;/asp:TextBox&gt; &lt;/p&gt; &lt;p align=&quot;center&quot;&gt; &lt;asp:Button class=&quot;button_long&quot; id=&quot;btnSave&quot; onclick=&quot;btnSave_Click&quot; runat=&quot;server&quot; Text=&quot;Save&quot;&gt;&lt;/asp:Button&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><br /><br /></p> <p>Stored Procedure:</p> <pre class="prettyprint">USE [CALL] GO /****** Object: StoredProcedure [dbo].[sp_D21ToDoInsert] Script Date: 04/03/2012 16:53:20 ******/ SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_D21ToDoInsert] ( @ToDoNote as Varchar(5000), @Priority as Varchar(2), @DateAdded as Date, @DateCompleted as Date ) AS IF NOT EXISTS ( SELECT ToDoNote FROM D21ToDoNotes WHERE ToDoNote = @ToDoNote AND Priority = @Priority AND DateAdded = @DateAdded AND DateCompleted = @DateCompleted ) BEGIN INSERT INTO D21ToDoNotes (ToDoNote, Priority, DateAdded, DateCompleted) VALUES (@ToDoNote, @Priority, @DateAdded, @DateCompleted) END</pre> <p><br> <br> </p> 2012-04-03T23:55:16-04:004914877http://forums.asp.net/p/1788863/4914877.aspx/1?Re+Stored+Procedure+troubleRe: Stored Procedure trouble <p>i think, the tbPriority.text is empty so change the</p> <pre class="prettyprint">Global.ASP.Global.SQLSingle(&quot;sp_D21ToDoInsert '&quot; &amp; tbNote.Text &amp; &quot;,&quot; &amp; tbPriority.Text &amp; &quot;,&quot; &amp; tbDateAdded.Text &amp; &quot;,&quot; &amp; tbDateCompleted.Text &amp; &quot;'&quot;)</pre> <p><br />adding single qoute</p> <pre class="prettyprint">Global.ASP.Global.SQLSingle("sp_D21ToDoInsert '" &amp; tbNote.Text &amp; "','" &amp; tbPiority.Text &amp; "','" &amp; tbDateAdded.Text &amp; "','" &amp; tbDateCompleted.Text &amp; "'") </pre> <p><br> <br> </p> 2012-04-04T00:12:09-04:004923174http://forums.asp.net/p/1788863/4923174.aspx/1?Re+Stored+Procedure+troubleRe: Stored Procedure trouble <p>Hi kahlshira,&nbsp;</p> <p>You could check these textboxes whther it has value or not before you use them. For example, Use IsNull() in your code.</p> <p>Thanks.</p> 2012-04-09T14:30:08-04:00