GridView-Mysql-bind Gridview control to SqlDataSource -problem-Delete Command

 DeleteCommand="DELETE FROM relatorios WHERE codigo=codigo">
 this works but delete everything

i have tryed this

WHERE codigo='codigo' ">

and
WHERE codigo=?codigo"> sintax error on mysql

 

the full code is below :

 

 

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" CellPadding="4" DataKeyNames="codigo"  AutoGenerateDeleteButton="True"  DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False">
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="codigo" HeaderText="codigo" ReadOnly="True" SortExpression="codigo" ApplyFormatInEditMode="True" />
            <asp:BoundField DataField="titulo" HeaderText="titulo" SortExpression="titulo" />
            <asp:BoundField DataField="data" HeaderText="data" SortExpression="data" />
            <asp:BoundField DataField="donativo" HeaderText="donativo" SortExpression="donativo" />
            <asp:BoundField DataField="linguagem" HeaderText="linguagem" SortExpression="linguagem" />
            <asp:CommandField ShowEditButton="True" />
            <asp:CommandField ShowDeleteButton="True" />
            <asp:CommandField ShowEditButton="True" />
        </Columns>
        <RowStyle BackColor="#EFF3FB" />
        <EditRowStyle BackColor="#2461BF" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dinisnetConnectionString %>"
        ProviderName="<%$ ConnectionStrings:dinisnetConnectionString.ProviderName %>"
        SelectCommand="SELECT codigo, titulo, data, donativo, linguagem FROM relatorios ORDER BY data DESC"
        DeleteCommand="DELETE FROM relatorios WHERE codigo=codigo">
        <DeleteParameters>
            <asp:ControlParameter Name="codigo" ControlID="GridView1"/>
        </DeleteParameters>
    </asp:SqlDataSource>

0
pedrodinis
10/27/2006 5:41:25 PM
asp.net.mysql 1929 articles. 0 followers. Follow

3 Replies
828 Views

Similar Articles

[PageSpeed] 51

 

 i have the solution :

use the parameter: 

<DeleteParameters>

<asp:Parameter Name="codigo" />

</DeleteParameters>

and in the sql use ? :

DeleteCommand="DELETE FROM relatorios WHERE codigo=?">

 this works

code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dinisnetConnectionString %>"

ProviderName="<%$ ConnectionStrings:dinisnetConnectionString.ProviderName %>"

SelectCommand="SELECT codigo, titulo, data, donativo, linguagem FROM relatorios ORDER BY data DESC"

DeleteCommand="DELETE FROM relatorios WHERE codigo=?">

<DeleteParameters>

<asp:Parameter Name="codigo" />

</DeleteParameters>

</asp:SqlDataSource>

0
pedrodinis
10/28/2006 10:19:18 AM
pedrodinis:

 DeleteCommand="DELETE FROM relatorios WHERE codigo=codigo">
 this works but delete everything


I'm not from Barcelona, but I know nothing either
0
Gervs
10/30/2006 8:36:04 PM

Of course everything is deleted, you in that syntax because you say delete from the table where the filedvalue matches itself. 


I'm not from Barcelona, but I know nothing either
0
Gervs
10/30/2006 8:40:05 PM
Reply:

Similar Artilces:

SQLdatasource + gridview + mysql
Hi,   I have a sqldatasource and a gridview. I work with a mysql 3.51 database. My problem is : When I try tu update a record through the update command of the gridview, it doesn't work.  Here is my code : <asp:SqlDataSource ID="SQL_Panier" runat=server ConnectionString="<%$ ConnectionStrings:Connection to NI %>" ProviderName="<%$ ConnectionStrings:Connection to NI.ProviderName %>" SelectCommand="selectcommand" UpdateCommand="Update Panier SET qtt=@qtt,commentaires=@commentaires WHERE email=?" DeleteCommand="delete from Panier where email=? and code=@code"&g...

Binding GridView Columns with controls outside the GridView
HiI already posted this issue but couldn't get the proper resolution so making it more clear;Problem is my controls are outside the grid. Like ive text boxes, for First Name and Last Name and dropdown for country. User can fill these fields for entering a new record and also update the existing by selecting it from the grid.Like user selects a row from the grid and its contents will be displayed on the textboxes and drop downs that are out side the grid.Hope i could explain it better now.  RegardsMohsin Shahzad You could use a DetailsView or FormView control that is linked to...

How to control the position of Gridview when Gridview is dynamically binding
Hello:  I have one Gridview on the left side. Each field has the hyperlink. When uses click the link, I need to pass this string to another dynamic Gridview control. This Gridview control is needed to dynamically bind. This Gridview control is need to be stay on the right side of the first Gridview.  Here is my dynamic binding Gridview code: TableRow row = new TableRow();tbl.Rows.Add(row);        ……….. GridView gv1 = new GridView();       ……cel1.Controls.Add(gv1); Here is my questions. How I could p...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Delete command is Gridview control
Hi I have added delete command in gridview and want to delete record on click of delete command. I want vb code(code behind) not HTML, is it possible,  i am using ASP.Net 3.5.  Please post code which you use for delete command.so it's more clear your question.:)here i post Gridview RowDelete command event which fired when Gridview row deleted. These articals may helps you http://msdn.microsoft.com/en-us/library/ms972940.aspx, http://www.codeproject.com/KB/aspnet/InsertingWithGridView.aspx             &nbs...

Binding Gridview to MySQl database
the problem i having isthe check box in advanced button which use to generate the update,insert and delete not allow to be check.is it possible to auto generate the update, inset and delete code? or we need to write it manually?thanks for help~!~ The checkbox is only available if the row with the primary is selected in the select/fill statement, and is part of the datatable. Make sure there's a primary key defined, and that it is defined on your datatable (if its not, right click the field in the dataset to set it). Then the option will be available. i have for sure the data key are the...

Updating Gridview with SqlDataSource with MySQL
Hey guys,Got one problem thats really making me tear out my hair. i know this may be simple for you guys, but its completely got me stumped.. i'm really appreciate f this forum and the users who helped me in the past, it really has helped me out in tight situations. Here's the problem, i have a populated gridview that has a single column (UserStatus) that i want to editable, the edit and cancel buttons both work, but i can't seem to update the single record that i updated without the whole column in the gridview getting updated to the same value that i put into the single one.. i...

Delete in GridView using OnClick method not Refreshing GridView Control
Hi, I have added a GridView control to my Personal Site and am using it to edit the content of the site, which I am storing in an MS Access database. The content is stored in a table called SiteContent with 4 columns: ContentCode, ContentLineNo, ContentElementType and ContentText. Without any code, the Delete LinkButton of the GridView was happily deleting rows from the table and refreshing immediately to show the change. However, I wanted the Delete LinkButton to also reduce the ContentLineNo column of each following row by 1, so I removed its CommandName="Delete" attribute and substitute...

MySQL and Gridview
Dear All,  I would like to use the MySQL .net connector to connect to my MySQL database. I can get the connection set up and display data from a table using the Gridview. But, I cannot control the layout options such as paging, insertion, editing and deletion. Is there a way that this can be achieved? The code that I have been using to connect to my MySQL database is below:  <%@ Page Language="VB" debug="true" %> <%@ Import Namespace = "System.Data" %> <%@ Import Namespace = "MySql.Data.MySqlClient" %><script languag...

To GridView or not to GridView
All, Just been banging my head against a brick wall thinking about ways to display data. I was wondering on the best way to display a DataSet in my application.  Immediate thoughts were GridView. Thing is when working with large data sets.  Suppose I have the following data set: Name             Cost                Month             YearTom       ...

Gridview control embedded in another gridview control
I am writing an ambulance crew scheduling application on the web and I need some help completing the last part.  I have an access database that has three tables: user table, shift table (describing the shifts available), and a schedule table (that stores shift by shift_id and user by user_id).  I have a gridview control that will display the available shifts but I cannot get the embedded gridview control that will display the user that is signed up for each shift to display because I cannot figure out how to use the OnRowDataBound method.  I need a simple VB example of how to...

Gridview to gridview
Hi,   I have a website with a gridview that shows the summary of one person's account, when they click select it reveals a 2nd gridview with details of that specific year. (it's actually 2 different databases) Now my problem is, when I click select on my top datagrid the bottom one doesn't update (by default, it selects the current year). Now I need to "refresh" the gridview without refreshing the page otherwise the content will bounce back to what it was originally, is there a way to update my gridview when I click select but only the gridview? Thanks in advance!  ...

SqlDataSource Control and Gridview control
Hi, I'm new to web development and learning about these controls.  The books teach you to bind the gridview control to an sqldatasource to perform delete,update,insert functions as well as to list the records in a table.  Is this standard practice for real world applications?  Or is there another way that should be used to display/manage table data in the gridview control? Thanks. Tulsi Using a sqldatasource is the best way I know of for binding data to a gridview.  (I'm pretty new to web development too, so maybe someone else can chime in if they know someth...

Any Grid for MySQL in .Net except the gridview in VS2005???
i using Connector 5.0.7, and if i use gridview to display the db data,the sorting,paging function all cant be use. any other tools to intro ? which can support for MySQL paging,sorting and other function. i found RadGrid, http://www.telerik.com/demos/aspnet/Grid/Examples/Programming/SimpleBinding/DefaultCS.aspx but i not sure it can fully utilize under MySQL or not? anyone try it before?C####################################### No one can help???C#######################################...

how to use delete button
 Hello,I am new to asp.netI use mysql database and mysql connector .net for my project. I use VB.net Gridview to display content of a table.below is my aspx code:                <asp:GridView ID="GridView1" runat="server">                    <Columns>                        &...

Web resources about - GridView-Mysql-bind Gridview control to SqlDataSource -problem-Delete Command - asp.net.mysql

Resources last updated: 1/1/2016 10:25:26 AM