我正在使用 devexpress,我有两个问题。
我的插入存储过程工作正常。
我指定了ASPxGridView.KeyFieldName
属性。
问题在于
delete
存储过程。我得到错误Procedure or function 'delete' expects parameter '@id', which was not supplied.
第二个问题是
update
存储过程。我得到错误Procedure or function updatetable has too many arguments specified.
我的源代码:
// sql脚本
USE [Data]
GO
/****** Object: StoredProcedure [dbo].[deletetable] Script Date: 06/12/2012
17:11:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Batch submitted through debugger: SQLQuery3.sql|0|0|C:\Users\Ali\
AppData\Local\Temp\~vsBA26.sql
ALTER procedure [dbo].[deletetable]
@id int
as
delete from Tablo where id= @id
USE [Data]
GO
/****** Object: StoredProcedure [dbo].[updatetable] Script Date: 06/12/2012
17:13:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Batch submitted through debugger: SQLQuery5.sql|0|0|C:\Users\Ali
\Desktop\SQLQuery5.sql
ALTER procedure [dbo].[updatetablo]
@name VARCHAR(50),
@surname VARCHAR(50),
@job VARCHAR(50),
@age INT,
@id INT
as
UPDATE Table
set name= @name, surname= @surname, job= @job, age= @age
where (id= @id)
//.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="devexpresskullanimi.aspx.cs"
Inherits="veritabani_uygulamasi.devexpresskullanimi" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.5.0,
Culture=neutral, PublicKeyToken=b88d1754d700e49a"
namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v10.2,
Version=10.2.5.0, Culture=neutral,
PublicKeyToken=b88d1754d700e49a"
namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
ClientIDMode="AutoID" CssFilePath="~/App_Themes/DevEx/{0}/styles.css"
CssPostfix="DevEx" DataSourceID="SqlDataSource1" Width="277px"
KeyFieldName="id">
<Columns>
<dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
<EditButton Visible="True">
</EditButton>
<NewButton Visible="True">
</NewButton>
<DeleteButton Visible="True">
</DeleteButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="name" VisibleIndex="0">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="surname" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="job" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="age" VisibleIndex="3">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="id" VisibleIndex="4">
</dx:GridViewDataTextColumn>
</Columns>
<Settings ShowFilterRow="True" />
<Images SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css">
<LoadingPanelOnStatusBar Url="~/App_Themes/DevEx/GridView/StatusBarLoading.gif">
</LoadingPanelOnStatusBar>
<LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
</LoadingPanel>
</Images>
<ImagesFilterControl>
<LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
</LoadingPanel>
</ImagesFilterControl>
<Styles CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx">
<Header ImageSpacing="5px" SortingImageSpacing="5px">
</Header>
<LoadingPanel ImageSpacing="5px">
</LoadingPanel>
</Styles>
<StylesEditors ButtonEditCellSpacing="0">
<ProgressBar Height="21px">
</ProgressBar>
</StylesEditors>
</dx:ASPxGridView>
<asp:Label ID="lblMessage" runat="server" Text="Label"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NetConnectionString %>"
SelectCommand="selecttablo" DeleteCommand="deletetable"
DeleteCommandType="StoredProcedure" InsertCommand="inserttable"
InsertCommandType="StoredProcedure" OldValuesParameterFormatString=""
SelectCommandType="StoredProcedure" UpdateCommand="updatetable"
UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="surname" Type="String" />
<asp:Parameter Name="job" Type="String" />
<asp:Parameter Name="age" Type="Int32" />
<asp:Parameter Name="id" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="surname" Type="String" />
<asp:Parameter Name="job" Type="String" />
<asp:Parameter Name="age" Type="Int32" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</body>
谁能看到问题可能是什么,或者给我一个关于如何解决这个问题的提示?