Jump to content

Help me ! Procedure in search.aspx


haibec

Recommended Posts

Hi guys !I want make a search.aspx ,when user type a name into text box will list all information of that userI have a procedureCREATE procedure dbo.TimItUser @name varchar(64)as declare @ID int select @ID = ID from _Char with (nolock) where CharName16 = @name if (@@rowcount = 0) begin return end declare @UserID int declare @gold bigint select @UserID = UserUserID from _User where ID = @ID select @gold = Gold from Account where UserID = @UserID if (@@rowcount = 0) begin return end declare @username varchar(128) select @username = AccID from Account with (nolock) where UserID = @UserID if (@@rowcount = 0) begin return end create table #temp_table ( username varchar(128), slot tinyint, itemid bigint, refid int default 0, optlevel tinyint null, variance bigint null, data int default 0, creator varchar(64) null, magnum tinyint default 0, mag1 bigint null, mag2 bigint null, mag3 bigint null, mag4 bigint null, mag5 bigint null, mag6 bigint null, mag7 bigint null, mag8 bigint null, mag9 bigint null, mag10 bigint null, mag11 bigint null, mag12 bigint null, Serial64 bigint ) declare @slot tinyint declare @itemid bigint declare @refid int declare @optlevel tinyint declare @variance bigint declare @data int declare @creator varchar(64) declare @magnum tinyint declare @mag1 bigint declare @mag2 bigint declare @mag3 bigint declare @mag4 bigint declare @mag5 bigint declare @mag6 bigint declare @mag7 bigint declare @mag8 bigint declare @mag9 bigint declare @mag10 bigint declare @mag11 bigint declare @mag12 bigint declare @Serial64 bigint declare @DescStrID128 Char declare cursor cursor fast_forward for select Slot, ItemID, RefItemID,DescStrID128, OptLevel, Variance, Data, CreaterName, magNum, mag1, mag2, mag3, mag4, mag5, mag6, mag7, mag8, mag9, mag10, mag11, mag12, Serial64 from (_Chest inner join _Items with (nolock) on _Chest.UserUserID = @UserID and _Chest.ItemID <> 0 and _Chest.ItemID = _Items.ID64 ) inner join _Common on _Common.ID = _Items.RefItemID open cursor fetch next from cursor into @slot, @itemid, @refid, @optlevel, @variance, @data, @creator, @magnum, @mag1, @mag2, @mag3, @mag4, @mag5, @mag6, @mag7, @mag8, @mag9, @mag10, @mag11, @mag12 , @Serial64 while @@fetch_status = 0 begin insert into #temp_table values ( @username, @slot, @itemid, @refid, @optlevel, @variance, @data, @creator, @magnum, @mag1, @mag2, @mag3, @mag4, @mag5, @mag6, @mag7, @mag8, @mag9, @mag10, @mag11, @mag12, @Serial64 ) fetch next from cursor into @slot, @itemid, @refid, @optlevel, @variance, @data, @creator, @magnum, @mag1, @mag2, @mag3, @mag4, @mag5, @mag6, @mag7, @mag8, @mag9, @mag10, @mag11, @mag12, @Serial64 end close cursor deallocate cursor insert #temp_table (username, slot, itemid ) values (@username, 255, @gold) select * from #temp_table drop table #temp_tableGO------------------------------------------------and I have a pages search.ASPX<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Search.aspx.cs" Inherits="SearchItem" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"> <asp:TextBox ID="txtSearch" runat="server" BackColor="#CCCC66"></asp:TextBox><asp:Button ID="btnSearch" runat="server" Font-Bold="True" ForeColor="#6600FF" Text="Search" /><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="name" DataSourceID="sqlSearch" GridLines="Horizontal" Width="805px"> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <Columns> <asp:BoundField DataField="DescStrID128" HeaderText="ItemCode" InsertVisible="False" ReadOnly="True" SortExpression="DescStrID128" /> <asp:BoundField DataField="OptLevel" HeaderText="Option" SortExpression="OptLevel" /> </Columns> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <AlternatingRowStyle BackColor="#F7F7F7" /> </asp:GridView> <asp:SqlDataSource ID="sqlSearch" runat="server" connectionString="Data Source=222.255.38.83;Initial Catalog=SRO_SHARD2;User ID=sangiaodich;pwd=hai@pao;database=SRO_SHARD2" ProviderName="System.Data.SqlClient" SelectCommand="TimItUser" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="txtSearch" Name="name" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource></asp:Content>In Browser appear error :DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'name'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'name'.Please help me

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...