473,666 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete row in GridView problem

On webform, I am populating a GridView from a SQLDatasource based on a MySQL
table named PIB.

There is no vb code involved. Everything is done in the source for the aspx
page, provided below. The update works fine, but a delete of a row produces
the following error:

Exception Details: System.Data.Odb c.OdbcException : ERROR [07001]
[MySQL][ODBC 3.51 Driver][mysqld-5.0.27]SQLBindParamete r not used for all
parameters
The table, PIB, involved has a primary key , Id, and I have worked on this
for some time with no solution. Does anyone know the answer?

Thanks

<body>
<form id="form1" runat="server">

<asp:TextBox ID="txtUid" runat="server" Style="z-index: 100; left: 14px;
position: absolute; top: 96px">JoeTestor </asp:TextBox>

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:MysoftwareCo nnectionString %>"

ProviderName="< %$ ConnectionStrin gs:MysoftwareCo nnectionString. ProviderName
%>"

SelectCommand=" Select * from PIB where Uid=?"

UpdateCommand=" UPDATE PIB SET Description = ?, Lat = ?, Link = ?, Lon = ?,
Map = ?, Title = ?, Uid = ? WHERE Id = ?"

DeleteCommand ="DELETE FROM PIB WHERE Id=?">
<SelectParamete rs>

<asp:ControlPar ameter ControlID="txtU id" Name="?" PropertyName="T ext" />

</SelectParameter s>
<UpdateParamete rs>

<asp:Paramete r Name="Descripti on" Type="String"/>

<asp:Paramete r Name="Lat" Type="String" />

<asp:Paramete r Name="Link" Type="String" />

<asp:Paramete r Name="Lon" Type="String" />

<asp:Paramete r Name="Map" Type="String" />

<asp:Paramete r Name="Title" Type="String" />

<asp:Paramete r Name="Uid" Type="String" />

</UpdateParameter s>
<DeleteParamete rs>

<asp:Paramete r Name="Id" Type="Int32"/>

</DeleteParameter s>

</asp:SqlDataSour ce>

<asp:GridView ID="GridView1" runat="server" AllowSorting="T rue"
AutoGenerateDel eteButton="True "

AutoGenerateEdi tButton="True" DataSourceID="S qlDataSource1" Style="z-index:
102;

left: 5px; position: absolute; top: 149px">

</asp:GridView>

</form>

</body>
Jun 27 '08 #1
2 2452
Hi William,

I tried the following code and it works fine. Please make sure your Primary
key is set as property to DataKeyNames property of GridView control.

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConflictDetecti on="CompareAllV alues"
ConnectionStrin g="<%$ ConnectionStrin gs:TestConnecti onString %>"
DeleteCommand=" DELETE FROM [MasterTable] WHERE [num] = @original_num AND
[fname] = @original_fname "
InsertCommand=" INSERT INTO [MasterTable] ([fname]) VALUES
(@fname)" OldValuesParame terFormatString ="original_{ 0}"
SelectCommand=" SELECT * FROM [MasterTable]"
UpdateCommand=" UPDATE [MasterTable] SET [fname] = @fname WHERE [num] =
@original_num AND [fname] = @original_fname ">
<DeleteParamete rs>
<asp:Paramete r Name="original_ num" Type="Int32" />
<asp:Paramete r Name="original_ fname" Type="String" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="fname" Type="String" />
<asp:Paramete r Name="original_ num" Type="Int32" />
<asp:Paramete r Name="original_ fname" Type="String" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="fname" Type="String" />
</InsertParameter s>
</asp:SqlDataSour ce>

</div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateCol umns="False" DataKeyNames="n um"
DataSourceID="S qlDataSource1">
<Columns>
<asp:BoundFie ld DataField="num" HeaderText="num "
InsertVisible=" False" ReadOnly="True"
SortExpression= "num" />
<asp:BoundFie ld DataField="fnam e" HeaderText="fna me"
SortExpression= "fname" />
<asp:CommandFie ld ShowDeleteButto n="True"
ShowEditButton= "True" />
</Columns>
</asp:GridView>

Hope this helps.

Regards,
Manish
www.ComponentOne.com

"William LaMartin" wrote:
On webform, I am populating a GridView from a SQLDatasource based on a MySQL
table named PIB.

There is no vb code involved. Everything is done in the source for the aspx
page, provided below. The update works fine, but a delete of a row produces
the following error:

Exception Details: System.Data.Odb c.OdbcException : ERROR [07001]
[MySQL][ODBC 3.51 Driver][mysqld-5.0.27]SQLBindParamete r not used for all
parameters
The table, PIB, involved has a primary key , Id, and I have worked on this
for some time with no solution. Does anyone know the answer?

Thanks

<body>
<form id="form1" runat="server">

<asp:TextBox ID="txtUid" runat="server" Style="z-index: 100; left: 14px;
position: absolute; top: 96px">JoeTestor </asp:TextBox>

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:MysoftwareCo nnectionString %>"

ProviderName="< %$ ConnectionStrin gs:MysoftwareCo nnectionString. ProviderName
%>"

SelectCommand=" Select * from PIB where Uid=?"

UpdateCommand=" UPDATE PIB SET Description = ?, Lat = ?, Link = ?, Lon = ?,
Map = ?, Title = ?, Uid = ? WHERE Id = ?"

DeleteCommand ="DELETE FROM PIB WHERE Id=?">
<SelectParamete rs>

<asp:ControlPar ameter ControlID="txtU id" Name="?" PropertyName="T ext" />

</SelectParameter s>
<UpdateParamete rs>

<asp:Paramete r Name="Descripti on" Type="String"/>

<asp:Paramete r Name="Lat" Type="String" />

<asp:Paramete r Name="Link" Type="String" />

<asp:Paramete r Name="Lon" Type="String" />

<asp:Paramete r Name="Map" Type="String" />

<asp:Paramete r Name="Title" Type="String" />

<asp:Paramete r Name="Uid" Type="String" />

</UpdateParameter s>
<DeleteParamete rs>

<asp:Paramete r Name="Id" Type="Int32"/>

</DeleteParameter s>

</asp:SqlDataSour ce>

<asp:GridView ID="GridView1" runat="server" AllowSorting="T rue"
AutoGenerateDel eteButton="True "

AutoGenerateEdi tButton="True" DataSourceID="S qlDataSource1" Style="z-index:
102;

left: 5px; position: absolute; top: 149px">

</asp:GridView>

</form>

</body>
Jun 27 '08 #2
Thanks for the reply. I tried to reply to this posting yesterday, but the
message was bounced back to me, so I will try again.

I actually got my code to work by removing all reference to the
deleteparameter s section:

<DeleteParamete rs>
<asp:Paramete r Name="Id" Type="Int32"/>
</DeleteParameter s>

"Manish" <Ma****@discuss ions.microsoft. comwrote in message
news:43******** *************** ***********@mic rosoft.com...
Hi William,

I tried the following code and it works fine. Please make sure your
Primary
key is set as property to DataKeyNames property of GridView control.

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConflictDetecti on="CompareAllV alues"
ConnectionStrin g="<%$ ConnectionStrin gs:TestConnecti onString
%>"
DeleteCommand=" DELETE FROM [MasterTable] WHERE [num] = @original_num AND
[fname] = @original_fname "
InsertCommand=" INSERT INTO [MasterTable] ([fname]) VALUES
(@fname)" OldValuesParame terFormatString ="original_{ 0}"
SelectCommand=" SELECT * FROM [MasterTable]"
UpdateCommand=" UPDATE [MasterTable] SET [fname] = @fname WHERE [num] =
@original_num AND [fname] = @original_fname ">
<DeleteParamete rs>
<asp:Paramete r Name="original_ num" Type="Int32" />
<asp:Paramete r Name="original_ fname" Type="String" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="fname" Type="String" />
<asp:Paramete r Name="original_ num" Type="Int32" />
<asp:Paramete r Name="original_ fname" Type="String" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="fname" Type="String" />
</InsertParameter s>
</asp:SqlDataSour ce>

</div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateCol umns="False" DataKeyNames="n um"
DataSourceID="S qlDataSource1">
<Columns>
<asp:BoundFie ld DataField="num" HeaderText="num "
InsertVisible=" False" ReadOnly="True"
SortExpression= "num" />
<asp:BoundFie ld DataField="fnam e" HeaderText="fna me"
SortExpression= "fname" />
<asp:CommandFie ld ShowDeleteButto n="True"
ShowEditButton= "True" />
</Columns>
</asp:GridView>

Hope this helps.

Regards,
Manish
www.ComponentOne.com

"William LaMartin" wrote:
>On webform, I am populating a GridView from a SQLDatasource based on a
MySQL
table named PIB.

There is no vb code involved. Everything is done in the source for the
aspx
page, provided below. The update works fine, but a delete of a row
produces
the following error:

Exception Details: System.Data.Odb c.OdbcException : ERROR [07001]
[MySQL][ODBC 3.51 Driver][mysqld-5.0.27]SQLBindParamete r not used for all
parameters
The table, PIB, involved has a primary key , Id, and I have worked on
this
for some time with no solution. Does anyone know the answer?

Thanks

<body>
<form id="form1" runat="server">

<asp:TextBox ID="txtUid" runat="server" Style="z-index: 100; left: 14px;
position: absolute; top: 96px">JoeTestor </asp:TextBox>

<asp:SqlDataSo urce ID="SqlDataSour ce1" runat="server"
ConnectionStri ng="<%$
ConnectionStri ngs:MysoftwareC onnectionString %>"

ProviderName=" <%$
ConnectionStri ngs:MysoftwareC onnectionString .ProviderName
%>"

SelectCommand= "Select * from PIB where Uid=?"

UpdateCommand= "UPDATE PIB SET Description = ?, Lat = ?, Link = ?, Lon =
?,
Map = ?, Title = ?, Uid = ? WHERE Id = ?"

DeleteComman d ="DELETE FROM PIB WHERE Id=?">
<SelectParamet ers>

<asp:ControlPa rameter ControlID="txtU id" Name="?" PropertyName="T ext" />

</SelectParameter s>
<UpdateParamet ers>

<asp:Paramet er Name="Descripti on" Type="String"/>

<asp:Paramet er Name="Lat" Type="String" />

<asp:Paramet er Name="Link" Type="String" />

<asp:Paramet er Name="Lon" Type="String" />

<asp:Paramet er Name="Map" Type="String" />

<asp:Paramet er Name="Title" Type="String" />

<asp:Paramet er Name="Uid" Type="String" />

</UpdateParameter s>
<DeleteParamet ers>

<asp:Paramet er Name="Id" Type="Int32"/>

</DeleteParameter s>

</asp:SqlDataSour ce>

<asp:GridVie w ID="GridView1" runat="server" AllowSorting="T rue"
AutoGenerateDe leteButton="Tru e"

AutoGenerateEd itButton="True" DataSourceID="S qlDataSource1"
Style="z-index:
102;

left: 5px; position: absolute; top: 149px">

</asp:GridView>

</form>

</body>

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13741
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
1
1847
by: Marc | last post by:
Hi, I made a detailsview for inserting records. I also made a gridview for editing and deleting the same records. The keyfield is an autonumbering field in Access (pcnr). My problem is: I can see the new inserted records in the gridview but I can't delete or edit them. When clicking on delete or edit link, nothing happens (no error either). All the others records (not inserted via the detailsview) can be edited and deleted.
1
6377
by: JasonK | last post by:
I would like to move the Delete button such that it displays one time in the footer row, rather than on every row. I've seen lots of questions asked on the subject around the net, but no answer that seems to solve the problem. I have tried a few things: - adding a button, setting it's command name to Delete. Problem with this is that the CommandArgument value does not get set to the SelectedIndex of the GridView. Instead it has the...
0
2658
by: Steve | last post by:
I have a gridview which uses an objectdatasource for its select and delete. The delete command uses the function below. The delete itself works but the extra logic which requires parameters AccountDebitID and AccountCreditID does not work. 'Delete a transaction Sub deletetrans(ByVal transactionid As Integer, ByVal transactionamount
4
2598
by: Wannabe | last post by:
I am using ASP.Net 2.0 and have a gridview on my page. I have everything working except the delete command. The page reloads except the row I am trying to delete is still there. I believe it is something really easy, but I cannot see it. The stored procedue works when run in QA. Can someone tell me what I am doing wrong/missing that is keeping the delete command from working in the gridview? Thank you. I am trying to delete a row out of...
1
8570
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but it doesn't seem to work at all. Below is my ASP.NET page, and further below, my VB.NET method that I am trying to call: <div id="admin-faq" class="page"> <h2>Site FAQs (Frequently Asked Questions)</h2>
0
2805
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation. What happened is if I select cancel on my confirmation button, it executes the griedview postback which i assigned in my code behind. Please see my codes below... Code beind: protected void gvDefectCatalog_RowDataBound(object sender,...
11
4071
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved, CrtdUser and Date And Edit and Delete buttons
2
2478
by: Danielle | last post by:
Hello all - Thank you in advance for any help you are able to provide. I am populating a gridview from a stored procuedure. The returned data is a name, phone number, email and guid of a contact in our database. I also need to use the Edit and Delete funtions in the gridview. Neither seems to be working as intended.
0
8363
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8645
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.