Avatar of ButlerTechnology
ButlerTechnology

asked on 

ASP.Net SQL Update failing

I have been trouble shooting an SQL update using a Grid View in ASP.Net.  I am at the point where I have created a simple table to verify that I can update the table using a stored procedure.   I am using VS 2010.
Create table Publisher
(PublisherID int Primary Key identity(1,1)
,PublisherName varchar(100))
go

insert into Publisher values ('Marvel')

go
Create proc PublisherSelect
@PublisherID int
as
Select PublisherID
     , PublisherName
from Publisher
go

Create proc PublisherUpdate
@PublisherID int
, @PublisherName varchar(100)
as
Update Publisher
set PublisherName = @PublisherName
where PublisherID = @PublisherID

Open in new window

I have verified that the stored procedure works on the sql server.

My data source is the following:
   
      <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:TimeCardString %>" 
        ProviderName="<%$ ConnectionStrings:TimeCardString.ProviderName %>" 
        SelectCommand="PublisherSelect" SelectCommandType="StoredProcedure" 
        UpdateCommand="PublisherUpdate" UpdateCommandType="StoredProcedure">
        <SelectParameters>
          <asp:ControlParameter ControlID="TextBox1" Name="PublisherID" 
            PropertyName="Text" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
          <asp:Parameter Name="PublisherID" Type="Int32" />
          <asp:Parameter Name="PublisherName" Type="String" />
        </UpdateParameters>
      </asp:SqlDataSource>

Open in new window

and my Grid is as follows:
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  
        DataKeyNames="PublisherID" DataSourceID="SqlDataSource1">
        <Columns>
          <asp:CommandField ShowEditButton="True" />
          <asp:BoundField DataField="PublisherID" HeaderText="PublisherID" 
            SortExpression="PublisherID" InsertVisible="False" ReadOnly="True" />
          <asp:BoundField DataField="PublisherName" HeaderText="PublisherName" 
            SortExpression="PublisherName" />
        </Columns>
      </asp:GridView>

Open in new window


When I attempt to update the record, I get error converting data type varchar to int.   If I let the SQL wizard create the update then things work as they should.
Microsoft SQL ServerWeb Applications

Avatar of undefined
Last Comment
ButlerTechnology
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

can you show the stord proc that updates your records?
ASKER CERTIFIED SOLUTION
Avatar of ButlerTechnology
ButlerTechnology

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ButlerTechnology
ButlerTechnology

ASKER

solution was unique to the environment.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo