473,473 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Trouble with parameterized query

Hello colleagues,

I have a ObjectDataSource wich is linked to a SQL Server 2005 database

I a gridview I have data and on each row a "Edit button" wich wil show the
selected record in editmode. When I click the update button I get this error
:

Parameterized Query '(@TmprValue float,@TmprRemark
nvarchar(4000),@TmprLocationID int' expects parameter @TmprRemark, which was
not supplied.

Code in my *aspx file :
<asp:GridView ID="grvTemperatures" runat="server" AllowPaging="True"
AutoGenerateColumns="False"
DataSourceID="objDataSrcTemp" SkinID="gridviewSkin">
<Columns>
<asp:BoundField DataField="TmprID" HeaderText="ID" ReadOnly="True"
>
<ItemStyle HorizontalAlign="Center" Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="TmprName" HeaderText="Name"
ReadOnly="True" >
<ItemStyle HorizontalAlign="Center" Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="TmprValue" HeaderText="Value" >
<ItemStyle HorizontalAlign="Right" Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="TmprRemark" HeaderText="Remark" >
<ItemStyle HorizontalAlign="Left" Width="300px" />
</asp:BoundField>
<asp:BoundField DataField="TmprLocationID" HeaderText="Location ID"
>
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="objDataSrcTemp" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetTemperatures" TypeName="dbTemperatures"
UpdateMethod="updTmpr" ConflictDetection="CompareAllValues">
<UpdateParameters>
<asp:Parameter Name="TmprValue" Type="Double" />
<asp:Parameter Name="TmprRemark" Type="String" />
<asp:Parameter Name="TmprLocationID" Type="Int32" />
<asp:Parameter Name="original_TmprID" Type="Int32" />
<asp:Parameter Name="original_TmprName" Type="String" />
<asp:Parameter Name="original_TmprValue" Type="Double" />
<asp:Parameter Name="original_TmprRemark" Type="String" />
<asp:Parameter Name="original_TmprLocationID" Type="Int32" />
</UpdateParameters>
</asp:ObjectDataSource>
<asp:Button ID="Button1" runat="server" Text="Button" />

And this is my Update method :

<DataObjectMethod(DataObjectMethodType.Update)_
Public Shared Sub updTmpr( _
ByVal TmprValue As Double, _
ByVal TmprRemark As String, _
ByVal TmprLocationID As Int32, _
ByVal original_TmprID As Int32, _
ByVal original_TmprName As String, _
ByVal original_TmprValue As Double, _
ByVal original_TmprRemark As String, _
ByVal original_TmprLocationID As Int32)
Dim updString As String = "UPDATE Tmpr " & _
"SET TmprValue = @TmprValue, TmprRemark = @TmprRemark,
TmprLocationID = @TmprLocationID " & _
"WHERE TmprID = @original_TmprID " & _
"AND TmprName = @original_TmprName " & _
"AND TmprValue = @original_TmprValue " & _
"AND TmprRemark = @original_TmprRemark " & _
"AND TmprLocationID = @original_TmprLocationID"
Dim cmd As New SqlCommand(updString, New
SqlConnection(dbCommand.GetConString))
cmd.Parameters.AddWithValue("TmprValue", TmprValue)
cmd.Parameters("TmprValue").DbType = DbType.Double
cmd.Parameters.AddWithValue("TmprRemark", TmprRemark)
cmd.Parameters("TmprRemark").DbType = DbType.String
cmd.Parameters.AddWithValue("TmprLocationID", TmprLocationID)
cmd.Parameters("TmprLocationID").DbType = DbType.Int32
cmd.Parameters.AddWithValue("original_TmprID", original_TmprID)
cmd.Parameters("original_TmprID").DbType = DbType.Int32
cmd.Parameters.AddWithValue("original_TmprName", original_TmprName)
cmd.Parameters("original_TmprName").DbType = DbType.String
cmd.Parameters.AddWithValue("original_TmprValue", original_TmprValue)
cmd.Parameters("original_Tmprvalue").DbType = DbType.Double
cmd.Parameters.AddWithValue("original_TmprRemark",
original_TmprRemark)
cmd.Parameters("original_TmprRemark").DbType = DbType.String
cmd.Parameters.AddWithValue("original_TmprLocation ID",
original_TmprLocationID)
cmd.Parameters("original_TmprLocationID").DbType = DbType.Int32
cmd.Connection.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
Throw ex
Finally
cmd.Connection.Close()
End Try
End Sub

What is going wrong ?
Thanks in advance for some help on this ...
Benny
Mar 17 '07 #1
0 1579

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

Similar topics

1
by: gary b | last post by:
Hello When I use a PreparedStatement (in jdbc) with the following query: SELECT store_groups_id FROM store_groups WHERE store_groups_id IS NOT NULL AND type = ? ORDER BY group_name
8
by: deko | last post by:
I'm trying to open a Recordset based on a parameterized query. I'm kind of new to parameterized queries, so I'm sure I'm missing something simple. Set qdfs = db.QueryDefs Set qdf =...
2
by: deko | last post by:
Is it possible to build a parameterized query from another parameterized query? I've tried two variations of this and can't seem to get it to work (using DAO). Any suggestions welcome! I...
1
by: Jorell | last post by:
Hey everyone, I am currently using Microsofts DataAccess Application block ( SQLHelper ) and what I want to do is use a parameterized query instead of just SQL. I can not use stored procedures,...
11
by: anony | last post by:
Hello, I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These...
2
by: JSheble | last post by:
After building a parameterized ADO query, is there a method or a statement where you could see the actual query, with the parameterized values included?? -- Using Opera's revolutionary e-mail...
8
by: Roland Hall | last post by:
In Access you use "*" + + "*", + can be replaced with & Calling a parameterized query in Access requires % be used in place of *, however, all that I have read show dynamic SQL passed to Access: ...
1
by: TF | last post by:
This group came through for me last time so here we go again. My page shows paint colors, brand name, product code, etc in a gridview with the background matching the paint color. Several links on...
3
by: xlar54 | last post by:
Is there a way to see the exact SQL being generated from a parameterized query? I am using this technique but am getting some strange SQL errors during execution and I would like to see the final...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...
1
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
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.