PROBLEM

  • 12 years ago

      Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

    Hi! I am facing problem in INSERT statement of SQL 2005 express. Actually I want to save data from one table to other two tables using SQL statement. I want to do something like that, when I will press Create button from DataGride Column. The data of that row of that Registration table will insert in some other table like Account and Directory. I have tried but I cannot do it. Please help me.

    <%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="AControlAccounts.aspx.cs" Inherits="Default2" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><table><tr><td style="width: 713px"></td></tr><tr><td style="width: 713px">    </td></tr>

    <asp:TemplateField HeaderText="Delete"><ItemTemplate><asp:LinkButton ID="Delete" runat="server" OnClientClick="return confirm ('Are you sure, you want to delete the record?');" CommandName="Delete" Font-Bold="true" Font-Size="Small"> Delete</asp:LinkButton></ItemTemplate></asp:TemplateField></Columns>    <HeaderStyle BackColor="#E0E0E0" Wrap="False" /></asp:GridView>    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"        SelectCommand="SELECT [RegId], [UserName], [Password], [FullName], [EMail], [City], [Country] FROM [Registration]"         DeleteCommand="DELETE FROM Registration WHERE (RegId = @RegId)" 

            <InsertParameters>            <asp       arameter Name="RegId" />        </InsertParameters>    </asp:SqlDataSource>        &nbsp;    </td></tr><tr><td style="width: 713px">    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" SkinID="button" Text="Cancel" /></td></tr></table>

     

  • 12 years ago
    That should be trivial... But you may use externed button, with its own handling and connection - command
  • 12 years ago
    hi Cbowman, Have a Button Field on the Grid, set its Command name to 'Select', and on its rowcommand, select the row number using 'e.EventArgument' and then you can easily select the record (i.e. every cell text in that row) and insert the same into another table. Regards, Royal

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The trouble with programmers is that you can never tell what a programmer is doing until it's too late.” - Seymour Cray