473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.Odbc.OdbcException: ERROR [07001]
[MySQL][ODBC 3.51 Driver][mysqld-5.0.27]SQLBindParameter 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:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MysoftwareConnectionString %>"

ProviderName="<%$ ConnectionStrings:MysoftwareConnectionString.Provi derName
%>"

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=?">
<SelectParameters>

<asp:ControlParameter ControlID="txtUid" Name="?" PropertyName="Text" />

</SelectParameters>
<UpdateParameters>

<asp:Parameter Name="Description" Type="String"/>

<asp:Parameter Name="Lat" Type="String" />

<asp:Parameter Name="Link" Type="String" />

<asp:Parameter Name="Lon" Type="String" />

<asp:Parameter Name="Map" Type="String" />

<asp:Parameter Name="Title" Type="String" />

<asp:Parameter Name="Uid" Type="String" />

</UpdateParameters>
<DeleteParameters>

<asp:Parameter Name="Id" Type="Int32"/>

</DeleteParameters>

</asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateDeleteButton="True"

AutoGenerateEditButton="True" DataSourceID="SqlDataSource1" Style="z-index:
102;

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

</asp:GridView>

</form>

</body>
Jun 27 '08 #1
2 2441
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:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
DeleteCommand="DELETE FROM [MasterTable] WHERE [num] = @original_num AND
[fname] = @original_fname"
InsertCommand="INSERT INTO [MasterTable] ([fname]) VALUES
(@fname)" OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [MasterTable]"
UpdateCommand="UPDATE [MasterTable] SET [fname] = @fname WHERE [num] =
@original_num AND [fname] = @original_fname">
<DeleteParameters>
<asp:Parameter Name="original_num" Type="Int32" />
<asp:Parameter Name="original_fname" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="fname" Type="String" />
<asp:Parameter Name="original_num" Type="Int32" />
<asp:Parameter Name="original_fname" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="fname" Type="String" />
</InsertParameters>
</asp:SqlDataSource>

</div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="num"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="num" HeaderText="num"
InsertVisible="False" ReadOnly="True"
SortExpression="num" />
<asp:BoundField DataField="fname" HeaderText="fname"
SortExpression="fname" />
<asp:CommandField ShowDeleteButton="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.Odbc.OdbcException: ERROR [07001]
[MySQL][ODBC 3.51 Driver][mysqld-5.0.27]SQLBindParameter 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:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MysoftwareConnectionString %>"

ProviderName="<%$ ConnectionStrings:MysoftwareConnectionString.Provi derName
%>"

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=?">
<SelectParameters>

<asp:ControlParameter ControlID="txtUid" Name="?" PropertyName="Text" />

</SelectParameters>
<UpdateParameters>

<asp:Parameter Name="Description" Type="String"/>

<asp:Parameter Name="Lat" Type="String" />

<asp:Parameter Name="Link" Type="String" />

<asp:Parameter Name="Lon" Type="String" />

<asp:Parameter Name="Map" Type="String" />

<asp:Parameter Name="Title" Type="String" />

<asp:Parameter Name="Uid" Type="String" />

</UpdateParameters>
<DeleteParameters>

<asp:Parameter Name="Id" Type="Int32"/>

</DeleteParameters>

</asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateDeleteButton="True"

AutoGenerateEditButton="True" DataSourceID="SqlDataSource1" 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
deleteparameters section:

<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32"/>
</DeleteParameters>

"Manish" <Ma****@discussions.microsoft.comwrote in message
news:43**********************************@microsof t.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:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:TestConnectionString
%>"
DeleteCommand="DELETE FROM [MasterTable] WHERE [num] = @original_num AND
[fname] = @original_fname"
InsertCommand="INSERT INTO [MasterTable] ([fname]) VALUES
(@fname)" OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [MasterTable]"
UpdateCommand="UPDATE [MasterTable] SET [fname] = @fname WHERE [num] =
@original_num AND [fname] = @original_fname">
<DeleteParameters>
<asp:Parameter Name="original_num" Type="Int32" />
<asp:Parameter Name="original_fname" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="fname" Type="String" />
<asp:Parameter Name="original_num" Type="Int32" />
<asp:Parameter Name="original_fname" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="fname" Type="String" />
</InsertParameters>
</asp:SqlDataSource>

</div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="num"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="num" HeaderText="num"
InsertVisible="False" ReadOnly="True"
SortExpression="num" />
<asp:BoundField DataField="fname" HeaderText="fname"
SortExpression="fname" />
<asp:CommandField ShowDeleteButton="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.Odbc.OdbcException: ERROR [07001]
[MySQL][ODBC 3.51 Driver][mysqld-5.0.27]SQLBindParameter 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:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:MysoftwareConnectionString %>"

ProviderName="<%$
ConnectionStrings:MysoftwareConnectionString.Prov iderName
%>"

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=?">
<SelectParameters>

<asp:ControlParameter ControlID="txtUid" Name="?" PropertyName="Text" />

</SelectParameters>
<UpdateParameters>

<asp:Parameter Name="Description" Type="String"/>

<asp:Parameter Name="Lat" Type="String" />

<asp:Parameter Name="Link" Type="String" />

<asp:Parameter Name="Lon" Type="String" />

<asp:Parameter Name="Map" Type="String" />

<asp:Parameter Name="Title" Type="String" />

<asp:Parameter Name="Uid" Type="String" />

</UpdateParameters>
<DeleteParameters>

<asp:Parameter Name="Id" Type="Int32"/>

</DeleteParameters>

</asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateDeleteButton="True"

AutoGenerateEditButton="True" DataSourceID="SqlDataSource1"
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
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....
1
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...
1
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...
0
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...
4
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...
1
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...
0
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....
11
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,...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.