Problem with changing Insert to use stored procedure (insert event fired but Insert not exec)

Hi all,

I'm got the club and didn't like that it required full rad and write access the clubsite db.  First thing I did was change the DB to match standards that I'm use to and create stored procedures for everything.


So now that I've done that I can't get my code to work with the insert.  I know the insert event is fired because if I change the name of the page in the insert event code is goes to that page.  I also know that the insert stored procedure is not being run because sql profiler is not showing it (only the select from the following page).  Below is the code for the page.


BTW yes I'm new to ASP.NET  and probably doing something totaly wrong with parameters.


Thanks for any help on this



<%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" %>

<%@ Register TagPrefix="Club" Namespace="ClubSite" %>

<%@ Register TagPrefix="Club" TagName="LoginBanner" Src="LoginBanner.ascx" %>

<%@ Register TagPrefix="Club" TagName="ImageThumbnail" Src="ImageThumbnail.ascx" %>

<script runat="server">

Function privatelabel(ByVal isprivate As Boolean) As String

If isprivate Then

Return "Album is private"


Return "Album is not private"

End If

End Function

Protected Sub uspAlbums_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)

If User.Identity.IsAuthenticated Then

e.Command.Parameters("@ownerID").Value = Membership.GetUser().ProviderUserKey


Throw New Exception("User must be authenticated to create an album")

End If

End Sub

Protected Sub uspAlbums_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)


End Sub


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

<div id="body">

<Club:LoginBanner ID="LoginBanner1" runat="server" />


Left column


<div id="columnleft">

<a name="content_start" id="content_start"></a>

<div class="leftblock">

<h2>Photo Albums</h2>




Right column


<div id="columnright">

<div class="rightblock">

<h2>Add new Album</h2>

<asp:SqlDataSource ID="uspAlbums" runat="server" ConnectionString="<%$ ConnectionStrings:ClubsiteDB %>"

SelectCommand="dbo.uspAlbums" SelectCommandType="StoredProcedure"

InsertCommand="dbo.uspAlbumsInsert" InsertCommandType="StoredProcedure"





<asp:FormParameter Name="ID" Type="int32" FormField="albumID" />



<asp:FormParameter Name="title" Type="string" FormField="albumTitle" />

<asp:FormParameter Name="description" Type="string" FormField="albumDescription" />

<asp:Parameter Name="parentID" Type="int32" DefaultValue="0" />

<asp:Parameter Name="ownerID" Type="int32" />

<asp:FormParameter Name="private" Type="boolean" FormField="privateAlbum" />



<asp:FormView ID="FormView1" runat="server" DataSourceID="uspAlbums" Width="445px" DefaultMode="Insert">




<td>Album Name</td>

<td><asp:TextBox ID="albumTitle" runat="server" Text='<%# eval("colTitle") %>' /></td>





<asp:TextBox ID="albumDescription" runat="server" Text='<%# eval("colDescription") %>' />






<asp:CheckBox ID="privateAlbum" runat="server" Checked='<%# eval("colPrivate") %>'

Text="Album is private and non visible to other users" />




<div style="text-align: right">

<Club:RolloverButton ID="GreenRolloverButton2" CommandName="Insert" Text="Add Album"

runat="server" />

<Club:RolloverButton ID="GreenRolloverButton3" CommandName="Cancel" Text="Cancel"

runat="server" />






<div class="clear2column"></div>



12/5/2005 12:16:39 AM 1219 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 20
Get it on Google Play
Get it on Apple App Store

Try removing the dbo. from the name of the stored procedures.
Brian O'Connell (MCAD) -
12/5/2005 1:21:44 AM

My select on the prior page is also qualified with "dbo." and it works.  None the less I tried and got the same results.  It's better to have stored procedures qualified so that if someone does manage to get another SP created with the same name but different users it still forces the dbo.storedprocedure.


At one point it was running but it was passing all the wrong stuff to the SP so I tried to change the code to pass only want is needed for SPs and it hasn't worked sence :)  It was passing something like "dbo.uspXXX @parm1, @parm2, @parm3, @parm4 (parm1=abc, parm2=,xyz, etc)"... basically some really goofy stuff.  Hopefully I get this fixed soon.  So far I like ASP.NET better than ColdFusion but this one thing is really getting me hung up.


Have a great one


12/5/2005 2:58:22 AM

Similar Artilces:

Insert not Inserting?
Hi guys, i've spent days trying to fig this out but it's passed me. i've basically got down to basics and I can't get information inserted into the db. I have a page with an accessdatasource with an insert command of : INSERT INTO [tblName] ([Name]) VALUES (?) I then have a button on the form with : protected void Button1_Click(object sender, EventArgs e) { AccessDataSource1.InsertParameters.Add("name","test"); Response.Write(AccessDataSource1.Insert().ToString()); }  the insert statement brings back 1 but when I goto the db it has the autogen...

Use Stored Procedure or insert template to insert a new record?
Hi there, I am using stored procedure for all my database website before I use .net 2. When I come to .net 2, I found almost all the videoes are using SP for select functions, and using insert template to add new ones. What's the differenence and which way is better? Thanks!  >which way is better?Whenever you can, use stored procedures - preferably your own, not some of the autogenerated horrors! If you want some help in generating them - see my post in plus the helper bits in

how to insert using Insert()
Could anybody give me or direct me to some good articles on how to use Insert() with sqlDataSource.. I did try google but I am trying to look for something to the point which shows how to use parameters.   Check out this article:'t forget to click "Mark as Answer" on the post(s) that helped you.NHibernate with Problem-Design-Solution sample applicationScott blog Check this link belowhttp://msdn2...

insert problem ?? when i insert records, sometimes inserting doesnt run. But if i close website and open website again, inserting run when open website again.. what can problem ? what should i do ?
hello friends  when i insert records, sometimes inserting doesnt run. But if i close website and open website again, inserting run when open website again.. what can problem ? what should i do ? i want inserting to run continuesly :) my inserting code are belowProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click  Dim yourUser As MembershipUser = Membership.GetUser(User.Identity.Name, True) Dim userGuid As System.Guid = DirectCast(yourUser.ProviderUserKey, Guid)Dim sds As New SqlDataSource() sds.ConnectionString = Configurati...

Problem in inserting data using insert command
Hi! I am trying to insert data into the databse using the following method. Protected Sub UserAddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UserAddButton.Click Dim addUserDS As New SqlDataSource() addUserDS.ConnectionString = ConfigurationManager.ConnectionStrings("RSSConnectionString").ToString() addUserDS.InsertCommandType = SqlDataSourceCommandType.Text addUserDS.InsertCommand = "INSERT INTO user (UserID, BuildingID) VALUES (@UserID, @BuildingID)" addUserDS.InsertParameters.Add(&quo...

insert problem :) DropDownList2.SelectedIndex = 2 in page_load.. when i change dropdownlist2.selectedindex from clicking dropdownlist2 with mouse, my insert button insert selected index=2.. but my ins
hello friends my code line is below DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf(DropDownList2.Items.FindByText(dt.Rows(0)("city").ToString().Trim())) in page_load i must use this code line in page_load to display a city in dropdownlist2.text in starting page so DropDownList2.SelectedIndex = 2 or 3 in page_load..  For example selectedindex=2 and city is London...when i change dropdownlist2.selectedindex from clicking dropdownlist2 with mouse (for example Manchester), my insert button insert selected index=2 (London).. but my insert button s...

Problems in using SQLDataSource with Stored Procedure to insert
I have this code: <asp:SqlDataSource ID="UserBDTeste" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"SelectCommand="AddUsuario" SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameter ControlID="textNome" Name="@Nome" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="textEmail" Name="@Email" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="...

How do you insert into two tables from one insert? Or even how would you using two inserts?
I currently insert into one table with:                 SqlCommand comm = new SqlCommand("INSERT INTO UsersTable (UserName, Password, Email) VALUES (@person, @pass, @email)", sqlConnection);                comm.Parameters.AddWithValue("@person", usrnmeLbl.Text);                comm.Parameters.AddWithValue("@pass", hiddenpassLbl.Text);     &n...

Getting Identity of Inserted Record using inserted event????
is there any way of getting the identity without using the "@@idemtity" in sql??? I'm trying to use the inserted event of ObjectDataSource, with Outputparameters, can anybody help me??? use scope_identity() is the best way. do not try to get last identity from VB, C#.Hope this help...

Trigger Problem Before Insert After Insert!
Dear Experts: I have a Sybase 5.5 database running on Network Server. I have a problem regarding firing triggers. when i have a trigger after insert order 1 and i am trying to fetch the primary key value in VB using the cursorlocation set to aduseclient, the values are not the same as they should be. however when i modify the trigger from After insert 1 to before insert 1 then it is working. any ideas?? thanks, John Vai Please show us all the relevant code: - the trigger - the VB code that's doing the FETCH - the layout of the table; e.g., t...

Problem with inserting a Record using textbox and stored procedure
Below is the code for a form with several textboxes that I would like to use the values from to insert a record using a stored procedure. I am not having any sucess. After entering all the values and clicking the submit button no record gets entered. Any help would be greatly appreciated. Thanks in advance Gary <%@ Page Language="VB" Debug="true" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.SqlClient" %> <script runat="server"> Sub Register_Click(ByVal sender A...

INSERT stored procedure problem: can't use @@identity?
Hello, I am using a stored procedure to insert values into multiple tables. I first insert a set of values inside a t_relation table and then insert the data related to that relation in a t_data table. The t_data table contains a foreign key, fk_t_relation_id, to the id of t_relation. I am creating 2 entries in the relation table with the stored procedure. One for data forecasts and one for data actuals. I therefore assign a variable @idActual and @idForecast to the ID's of the new entries in t_relation. These variables are used to assign the foreign key in the t_data table. ...

Which event on Formview Insert should I use to Insert Record and move to another page?
I have an unbound Formview that is used for adding a new Work Order against an equipment item. In the ItemInserting event I have code that generates the pk (WorkOrderID) for the table that the record is being inserted to. I want to put a Try_Catch there which would allow me to redirect the user if for some reason the sql server is down and a new WorkOrderID did not get generated. If succesful then I want to provide a message box that tells the user the new WorkOrderID and allows them to either go to another web page to further document the Work Order or add another Work Order.  Where ...

how to excute stored procedure that insert record and return last inserted value
Dear all, I am using C# , and sql server 2005. Let me explain the situation. I have written procedure to insert data into the table and return last inserted value by @@identity variable. Now my question is how do I execute this process so that I can Get last inserted variable values       Please help  thanks    I'm not sure I'm following completely.  If you are inserting data into SQL via this stored procedure, I'm assuming the data to be inserted is passed to the SP as SQL parameters.  Are you saying you want...

Web resources about - Problem with changing Insert to use stored procedure (insert event fired but Insert not exec) -

Invasiveness of surgical procedures - Wikipedia, the free encyclopedia
There are three main categories which describe the invasiveness of surgical procedures . These are: non-invasive procedures , minimally invasive ...

Procedure is more a snap than a snip
A QUEENSLAND doctor is bidding to set an unusual world record by performing the highest number of vasectomies in one day, with the help of fellow ...

Will Paul Ryan Make His Mark As Speaker By Instituting Impeachment Procedures Against President Obama ...
Wisconsin Ayn Rand devotee Paul Ryan just started his new job as Speaker of the dysfunctional House Republicans. And he's already headed for ...

Are patients charged drastically different prices for the same medical procedure? - Videos - CBS News ...
Patients are often charged drastically different prices for the same medical procedures and research may link later bedtimes with gaining weight. ...

Vin Scully To Miss Dodgers Postseason After Medical Procedure
... , who has been calling Dodgers games since the Truman administration, will miss the team’s playoff run as he recovers from a medical procedure. ...

FDA finds flaws in Theranos' nanotainers and quality control procedures
... to Theranos' blood testing technology comes from the US Food and Drug Administration, which found flaws in the company's quality control procedures. ...

'Daily Show' Host Trevor Noah Hospitalized for Emergency Procedure
'Daily Show' Host Trevor Noah Hospitalized for Emergency Procedure

Hall Of Fame Broadcaster Vin Scully Has Medical Procedure, Will Miss All Of 2015 Postseason
While the Dodgers will be in the 2015 MLB postseason, their Hall of Fame broadcaster, won't. Here's details on Vin Scully.

US AIRPORT SECURITY CONCERNS DHS to heighten procedures in light of Russian jet bombing theory, poor ...
US AIRPORT SECURITY CONCERNS DHS to heighten procedures in light of Russian jet bombing theory, poor test performances by TSA screeners

Concession: Ryan promises Freedom Caucus he’ll delay discussion of reforming procedure for removing the ...
Compromise. Like I said this morning, it sounds like they did a little horse-trading at their summit. Ryan wants them to give up their right ...

Resources last updated: 11/27/2015 3:19:05 AM