Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > .NET Framework > Forum > asp.net ช่วยตรวจสอบโค้ดไห้หน่อยครับว่าผิดตรงไหนลบข้อมูลจาก base Mysql ไม่ได้



 

asp.net ช่วยตรวจสอบโค้ดไห้หน่อยครับว่าผิดตรงไหนลบข้อมูลจาก base Mysql ไม่ได้

 



Topic : 074880



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์




Code (ASP)
<div style="height:500px">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" 
        BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="รหัสผู้ค้า" 
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:CommandField ButtonType="Button" CancelText="ยกเลิก" DeleteText="ลบ" 
                EditText="แก้ไข" InsertText="เพิ่ม" ShowDeleteButton="True" 
                ShowEditButton="True" ShowSelectButton="True" />
            <asp:BoundField DataField="รหัสผู้ค้า" HeaderText="รหัสผู้ค้า" 
                InsertVisible="False" ReadOnly="True" SortExpression="รหัสผู้ค้า" />
            <asp:BoundField DataField="ชื่อบริษัท" HeaderText="ชื่อบริษัท" 
                SortExpression="ชื่อบริษัท" />
            <asp:BoundField DataField="รหัสบริษัท" HeaderText="รหัสบริษัท" 
                SortExpression="รหัสบริษัท" />
            <asp:BoundField DataField="วันที่สั่งซื้อ" HeaderText="วันที่สั่งซื้อ" 
                SortExpression="วันที่สั่งซื้อ" />
            <asp:BoundField DataField="รายละเอียดสินค้า" HeaderText="รายละเอียดสินค้า" 
                SortExpression="รายละเอียดสินค้า" />
            <asp:BoundField DataField="จำนวน" HeaderText="จำนวน" SortExpression="จำนวน" />
            <asp:BoundField DataField="ราคา" HeaderText="ราคา" SortExpression="ราคา" />
        </Columns>
        <EmptyDataTemplate>
            ไม่มีข้อมูลข้อมูล
        </EmptyDataTemplate>
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
        <RowStyle ForeColor="#000066" />
        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#007DBB" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#00547E" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:EcommerceConnectionString %>" 
        DeleteCommand="DELETE FROM [suply] WHERE [spid] = @original_spid AND (([compnayname] = @original_compnayname) OR ([compnayname] IS NULL AND @original_compnayname IS NULL)) AND (([companycode] = @original_companycode) OR ([companycode] IS NULL AND @original_companycode IS NULL)) AND (([orderdate] = @original_orderdate) OR ([orderdate] IS NULL AND @original_orderdate IS NULL)) AND (([orderdetail] = @original_orderdetail) OR ([orderdetail] IS NULL AND @original_orderdetail IS NULL)) AND (([orderamount] = @original_orderamount) OR ([orderamount] IS NULL AND @original_orderamount IS NULL)) AND (([orderprice] = @original_orderprice) OR ([orderprice] IS NULL AND @original_orderprice IS NULL))" 
        InsertCommand="INSERT INTO [suply] ([compnayname], [companycode], [orderdate], [orderdetail], [orderamount], [orderprice]) VALUES (@compnayname, @companycode, @orderdate, @orderdetail, @orderamount, @orderprice)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT [spid]AS รหัสผู้ค้า, [compnayname] AS ชื่อบริษัท, [companycode] AS รหัสบริษัท, [orderdate] AS วันที่สั่งซื้อ, [orderdetail] AS รายละเอียดสินค้า, [orderamount] AS จำนวน, [orderprice] AS ราคา FROM [suply]" 
        UpdateCommand="UPDATE [suply] SET [compnayname] = @compnayname, [companycode] = @companycode, [orderdate] = @orderdate, [orderdetail] = @orderdetail, [orderamount] = @orderamount, [orderprice] = @orderprice WHERE [spid] = @original_spid AND (([compnayname] = @original_compnayname) OR ([compnayname] IS NULL AND @original_compnayname IS NULL)) AND (([companycode] = @original_companycode) OR ([companycode] IS NULL AND @original_companycode IS NULL)) AND (([orderdate] = @original_orderdate) OR ([orderdate] IS NULL AND @original_orderdate IS NULL)) AND (([orderdetail] = @original_orderdetail) OR ([orderdetail] IS NULL AND @original_orderdetail IS NULL)) AND (([orderamount] = @original_orderamount) OR ([orderamount] IS NULL AND @original_orderamount IS NULL)) AND (([orderprice] = @original_orderprice) OR ([orderprice] IS NULL AND @original_orderprice IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_spid" Type="Int32" />
            <asp:Parameter Name="original_compnayname" Type="String" />
            <asp:Parameter Name="original_companycode" Type="String" />
            <asp:Parameter DbType="Date" Name="original_orderdate" />
            <asp:Parameter Name="original_orderdetail" Type="String" />
            <asp:Parameter Name="original_orderamount" Type="Int32" />
            <asp:Parameter Name="original_orderprice" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="compnayname" Type="String" />
            <asp:Parameter Name="companycode" Type="String" />
            <asp:Parameter DbType="Date" Name="orderdate" />
            <asp:Parameter Name="orderdetail" Type="String" />
            <asp:Parameter Name="orderamount" Type="Int32" />
            <asp:Parameter Name="orderprice" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="compnayname" Type="String" />
            <asp:Parameter Name="companycode" Type="String" />
            <asp:Parameter DbType="Date" Name="orderdate" />
            <asp:Parameter Name="orderdetail" Type="String" />
            <asp:Parameter Name="orderamount" Type="Int32" />
            <asp:Parameter Name="orderprice" Type="Int32" />
            <asp:Parameter Name="original_spid" Type="Int32" />
            <asp:Parameter Name="original_compnayname" Type="String" />
            <asp:Parameter Name="original_companycode" Type="String" />
            <asp:Parameter DbType="Date" Name="original_orderdate" />
            <asp:Parameter Name="original_orderdetail" Type="String" />
            <asp:Parameter Name="original_orderamount" Type="Int32" />
            <asp:Parameter Name="original_orderprice" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
        <asp:HyperLink ID="HyperLink1" runat="server" 
            NavigateUrl="~/ReportSuplyShow.aspx" Target="_blank">พิมพ์รายงานการสั่งซื้อ</asp:HyperLink>
   </div>
   <div>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="spid" 
        DataSourceID="SqlDataSource2" DefaultMode="Insert">
        <EditItemTemplate>
            spid:
            <asp:Label ID="spidLabel1" runat="server" Text='<%# Eval("spid") %>' />
            <br />
            companycode:
            <asp:TextBox ID="companycodeTextBox" runat="server" 
                Text='<%# Bind("companycode") %>' />
            <br />
            compnayname:
            <asp:TextBox ID="compnaynameTextBox" runat="server" 
                Text='<%# Bind("compnayname") %>' />
            <br />
            orderdate:
            <asp:TextBox ID="orderdateTextBox" runat="server" 
                Text='<%# Bind("orderdate") %>' />
            <br />
            orderdetail:
            <asp:TextBox ID="orderdetailTextBox" runat="server" 
                Text='<%# Bind("orderdetail") %>' />
            <br />
            orderamount:
            <asp:TextBox ID="orderamountTextBox" runat="server" 
                Text='<%# Bind("orderamount") %>' />
            <br />
            orderprice:
            <asp:TextBox ID="orderpriceTextBox" runat="server" 
                Text='<%# Bind("orderprice") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            รหัสบริษัท:
            <asp:TextBox ID="companycodeTextBox" runat="server" 
                Text='<%# Bind("companycode") %>' />
            <br />
            ชื่อบริษัท:
            <asp:TextBox ID="compnaynameTextBox" runat="server" 
                Text='<%# Bind("compnayname") %>' />
            <br />
            วันที่สั่งซื้อ:
            <asp:TextBox ID="orderdateTextBox" runat="server" 
                Text='<%# Bind("orderdate") %>' />
            &nbsp;2012/2/29<br />รายละเอียด:
            <asp:TextBox ID="orderdetailTextBox" runat="server" 
                Text='<%# Bind("orderdetail") %>' />
            <br />
            จำนวน:
            <asp:TextBox ID="orderamountTextBox" runat="server" 
                Text='<%# Bind("orderamount") %>' />
            <br />
            ราคา:
            <asp:TextBox ID="orderpriceTextBox" runat="server" 
                Text='<%# Bind("orderprice") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            spid:
            <asp:Label ID="spidLabel" runat="server" Text='<%# Eval("spid") %>' />
            <br />
            companycode:
            <asp:Label ID="companycodeLabel" runat="server" 
                Text='<%# Bind("companycode") %>' />
            <br />
            compnayname:
            <asp:Label ID="compnaynameLabel" runat="server" 
                Text='<%# Bind("compnayname") %>' />
            <br />
            orderdate:
            <asp:Label ID="orderdateLabel" runat="server" Text='<%# Bind("orderdate") %>' />
            <br />
            orderdetail:
            <asp:Label ID="orderdetailLabel" runat="server" 
                Text='<%# Bind("orderdetail") %>' />
            <br />
            orderamount:
            <asp:Label ID="orderamountLabel" runat="server" 
                Text='<%# Bind("orderamount") %>' />
            <br />
            orderprice:
            <asp:Label ID="orderpriceLabel" runat="server" 
                Text='<%# Bind("orderprice") %>' />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Edit" />
            &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New" />
        </ItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:EcommerceConnectionString %>" 
        DeleteCommand="DELETE FROM [suply] WHERE [spid] = @spid" 
        InsertCommand="INSERT INTO [suply] ([companycode], [compnayname], [orderdate], [orderdetail], [orderamount], [orderprice]) VALUES (@companycode, @compnayname, @orderdate, @orderdetail, @orderamount, @orderprice)" 
        SelectCommand="SELECT * FROM [suply]" 
        UpdateCommand="UPDATE [suply] SET [companycode] = @companycode, [compnayname] = @compnayname, [orderdate] = @orderdate, [orderdetail] = @orderdetail, [orderamount] = @orderamount, [orderprice] = @orderprice WHERE [spid] = @spid">
        <DeleteParameters>
            <asp:Parameter Name="spid" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="companycode" Type="String" />
            <asp:Parameter Name="compnayname" Type="String" />
            <asp:Parameter DbType="Date" Name="orderdate" />
            <asp:Parameter Name="orderdetail" Type="String" />
            <asp:Parameter Name="orderamount" Type="Int32" />
            <asp:Parameter Name="orderprice" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="companycode" Type="String" />
            <asp:Parameter Name="compnayname" Type="String" />
            <asp:Parameter DbType="Date" Name="orderdate" />
            <asp:Parameter Name="orderdetail" Type="String" />
            <asp:Parameter Name="orderamount" Type="Int32" />
            <asp:Parameter Name="orderprice" Type="Int32" />
            <asp:Parameter Name="spid" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
   </div>
    <br />
    <br />



มันลบข้อมูลจากเบสไม่ได้อ่ะครับ error ก็ไม่ฟ้อง



Tag : ASP.NET, Web (ASP.NET)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-03-02 02:57:25 By : kahapol View : 1139 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

เขียนแบบนี้หาและ Debug ยากครับ ทำไมไม่ลองเขียน code เองครับ ไม่ยากเลย

Code (VB.NET)
		IF e.CommandName = "Delete" Then
			'*** CustomerID ***'
			Dim lblCustomerID As Label = CType(e.Item.FindControl("lblCustomerID"),Label)
			strSQL = "DELETE FROM customer WHERE CustomerID = '"& lblCustomerID.Text &"' "
			objCmd = New MySqlCommand(strSQL, objConn)
			objCmd.ExecuteNonQuery()
			BindData()
		End IF


Go to : ASP.NET MySQL Delete Record






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-02 05:59:07 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : asp.net ช่วยตรวจสอบโค้ดไห้หน่อยครับว่าผิดตรงไหนลบข้อมูลจาก base Mysql ไม่ได้
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่