Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2005, 06:01 PM
Authorized User
 
Join Date: May 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jturlington
Default ASP.net SQL Update Stored Procedure not updating.

My page displays the info in the text boxes, but when we run the click sub for the update button it returns the info that it has been updated sucessfully. Here is the page code and below that is the stored procedure it uses, but not update in the database.
Code:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="The Car Masseuse - Profile Update" %>
<%@Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim myConnection As New SqlConnection("server=localhost;uid=###;pwd=###;database=###;")
        Dim myCommand As New SqlDataAdapter("select * from users where username='" & Request.Cookies("username").Value & "'", myConnection)
        Dim ds As New DataSet()
        myCommand.Fill(ds, "users")
        lblID.Text = ds.Tables(0).Rows(0)("id").ToString()
        txtName.Text = ds.Tables(0).Rows(0)("name").ToString()
        txtAdd.Text = ds.Tables(0).Rows(0)("address").ToString()
        txtCity.Text = ds.Tables(0).Rows(0)("City").ToString()
        txtSt.Text = ds.Tables(0).Rows(0)("st").ToString()
        txtZIP.Text = ds.Tables(0).Rows(0)("zip").ToString()
        txtPhone.Text = ds.Tables(0).Rows(0)("phone").ToString()
        txtEmail.Text = ds.Tables(0).Rows(0)("email").ToString()
    End Sub
    Protected Sub butUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim sqlConn As SqlConnection = New SqlConnection("server=localhost;uid=###;pwd=###;database=###;")
        Dim sqlSel As SqlCommand
        sqlSel = New SqlCommand
        sqlSel.Connection = sqlConn
        sqlSel.CommandText = "userUpdate"
        sqlSel.CommandType = Data.CommandType.StoredProcedure
        sqlSel.Parameters.AddWithValue("@id", lblID.Text)
        sqlSel.Parameters.AddWithValue("@name", txtName.Text)
        sqlSel.Parameters.AddWithValue("@address", txtAdd.Text)
        sqlSel.Parameters.AddWithValue("@city", txtCity.Text)
        sqlSel.Parameters.AddWithValue("@st", txtSt.Text)
        sqlSel.Parameters.AddWithValue("@zip", txtZIP.Text)
        sqlSel.Parameters.AddWithValue("@phone", txtPhone.Text)
        sqlSel.Parameters.AddWithValue("@email", txtEmail.Text)
        Dim selParm As SqlParameter = sqlSel.Parameters.Add("ReturnValue", SqlDbType.Int, 1)
        selParm.Direction = ParameterDirection.ReturnValue
        sqlConn.Open()
        sqlSel.ExecuteNonQuery()
        If selParm.Value = 0 Then
            lblstatus.Text = "Update Sucessful!"
            Panel1.Visible = False
        End If
        sqlConn.Close()
    End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table align="center" width="545px"><tr><td align="right" class="texttitle1">Update Profile</td></tr><tr><td></td></tr>
<tr><td>
    <asp:Label ID="lblstatus" runat="server">Here you can update your contact information.</asp:Label>
<asp:Panel ID="Panel1" runat="server">

    <asp:Label runat="server" ID="lblUserId">User ID #:</asp:Label><asp:Label runat="server" ID="lblID"></asp:Label><br />
    <asp:Label runat="server" ID="lblName">Name: </asp:Label><asp:TextBox ID="txtName" runat="server" cssclass="text"></asp:TextBox><br />
    <asp:Label runat="server" ID="lblAddress">Address: </asp:Label><asp:TextBox ID="txtAdd" runat="server" cssclass="text"></asp:TextBox><br />
    <asp:Label runat="server" ID="lblCity">City: </asp:Label><asp:TextBox ID="txtCity" runat="server" cssclass="text"></asp:TextBox><br />
    <asp:Label runat="server" ID="lblState">State: </asp:Label><asp:TextBox ID="txtSt" runat="server" cssclass="text"></asp:TextBox><br />
    <asp:Label runat="server" ID="lblZip">Zip Code: </asp:Label><asp:TextBox ID="txtZIP" runat="server" cssclass="text"></asp:TextBox><br />
    <asp:Label runat="server" ID="lblPhone">Phone Number: </asp:Label><asp:TextBox ID="txtPhone" runat="server" cssclass="text"></asp:TextBox><br />
    <asp:Label runat="server" ID="lblEmail">Email: </asp:Label><asp:TextBox ID="txtEmail" runat="server" cssclass="text"></asp:TextBox><br />
    <asp:Button ID="butUpdate" runat="server" Text="Update Profile" OnClick="butUpdate_Click" /></asp:Panel></td></tr></table>
</asp:Content>
Code:
CREATE  PROCEDURE userUpdate
(
  @id bigint,
  @name varchar(50),
  @address varchar(50),
  @city varchar(50),
  @st varchar(2),
  @zip varchar(5),
  @phone varchar(10),
  @email varchar(75)
)
AS
UPDATE users SET [name]=@name,address=@address,city=@city,st=@st,zip=@zip,phone=@phone,email=@email where [id] = @id
Return (0)
GO
Any help would be greatly appreciated.

Thanks

Thank you,
Jon Turlington
__________________
Thank you,
Jon Turlington





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing value in a stored procedure using ASP.NET hbansal ASP.NET 1.0 and 1.1 Professional 5 July 30th, 2007 12:36 AM
sql connectivity using stored procedure in asp.net krishna kumari Classic ASP Databases 2 January 17th, 2007 02:45 PM
ASP.NET & SQL Server 2K Stored Procedure kwilliams ASP.NET 2.0 Basics 7 May 10th, 2006 12:55 AM
Update Tables in Stored Procedure Talsiter SQL Server 2005 1 April 10th, 2006 03:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.