我想将aspnet_users中的UserName插入到我自己的名为Members的表中。我的sqldatasource如下所示。在InsertParameters的最后,我添加了ProfileParameter,但它不起作用。只是为了获得值,我在insertcommand中硬编码了'testhere'值。我的SQLDatasource如下所示。
请帮助!!!
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
OnInserted= "on_inserted"
OnUpdated = "on_updated"
ConnectionString="<%$ ConnectionStrings:test1ConnectionString %>"
DeleteCommand="DELETE FROM [member] WHERE [id] = @id"
InsertCommand="INSERT INTO [member] ([firstname], [lastname],[username]) VALUES (@firstname, @lastname,'testhere');
set @id = @@identity"
SelectCommand="SELECT * FROM [member] WHERE ([id] = @id)"
UpdateCommand="UPDATE [member] SET [firstname] = @firstname, [lastname] = @lastname WHERE [id] = @id"
onselecting="SqlDataSource1_Selecting">
<SelectParameters>
<asp:QueryStringParameter Name="id" QueryStringField="id" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="firstname" Type="String" />
<asp:Parameter Name="lastname" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="id" Type=Int32 Direction=Output />
<asp:Parameter Name="firstname" Type="String" />
<asp:Parameter Name="lastname" Type="String" />
<asp:ProfileParameter Name="username" Type=String />
</InsertParameters>
</asp:SqlDataSource>
答案 0 :(得分:0)
好的......作为一个简单的:
魔术!