473,657 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with parameterized query

Hello colleagues,

I have a ObjectDataSourc e 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,@TmprRema rk
nvarchar(4000), @TmprLocationID int' expects parameter @TmprRemark, which was
not supplied.

Code in my *aspx file :
<asp:GridView ID="grvTemperat ures" runat="server" AllowPaging="Tr ue"
AutoGenerateCol umns="False"
DataSourceID="o bjDataSrcTemp" SkinID="gridvie wSkin">
<Columns>
<asp:BoundFie ld DataField="Tmpr ID" HeaderText="ID" ReadOnly="True"
>
<ItemStyle HorizontalAlign ="Center" Width="50px" />
</asp:BoundField>
<asp:BoundFie ld DataField="Tmpr Name" HeaderText="Nam e"
ReadOnly="True" >
<ItemStyle HorizontalAlign ="Center" Width="50px" />
</asp:BoundField>
<asp:BoundFie ld DataField="Tmpr Value" HeaderText="Val ue" >
<ItemStyle HorizontalAlign ="Right" Width="50px" />
</asp:BoundField>
<asp:BoundFie ld DataField="Tmpr Remark" HeaderText="Rem ark" >
<ItemStyle HorizontalAlign ="Left" Width="300px" />
</asp:BoundField>
<asp:BoundFie ld DataField="Tmpr LocationID" HeaderText="Loc ation ID"
>
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:CommandFie ld ButtonType="But ton" ShowEditButton= "True" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="objDataSrcT emp" runat="server"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etTemperatures" TypeName="dbTem peratures"
UpdateMethod="u pdTmpr" ConflictDetecti on="CompareAllV alues">
<UpdateParamete rs>
<asp:Paramete r Name="TmprValue " Type="Double" />
<asp:Paramete r Name="TmprRemar k" Type="String" />
<asp:Paramete r Name="TmprLocat ionID" Type="Int32" />
<asp:Paramete r Name="original_ TmprID" Type="Int32" />
<asp:Paramete r Name="original_ TmprName" Type="String" />
<asp:Paramete r Name="original_ TmprValue" Type="Double" />
<asp:Paramete r Name="original_ TmprRemark" Type="String" />
<asp:Paramete r Name="original_ TmprLocationID" Type="Int32" />
</UpdateParameter s>
</asp:ObjectDataS ource>
<asp:Button ID="Button1" runat="server" Text="Button" />

And this is my Update method :

<DataObjectMeth od(DataObjectMe thodType.Update )_
Public Shared Sub updTmpr( _
ByVal TmprValue As Double, _
ByVal TmprRemark As String, _
ByVal TmprLocationID As Int32, _
ByVal original_TmprID As Int32, _
ByVal original_TmprNa me As String, _
ByVal original_TmprVa lue As Double, _
ByVal original_TmprRe mark As String, _
ByVal original_TmprLo cationID As Int32)
Dim updString As String = "UPDATE Tmpr " & _
"SET TmprValue = @TmprValue, TmprRemark = @TmprRemark,
TmprLocationID = @TmprLocationID " & _
"WHERE TmprID = @original_TmprI D " & _
"AND TmprName = @original_TmprN ame " & _
"AND TmprValue = @original_TmprV alue " & _
"AND TmprRemark = @original_TmprR emark " & _
"AND TmprLocationID = @original_TmprL ocationID"
Dim cmd As New SqlCommand(updS tring, New
SqlConnection(d bCommand.GetCon String))
cmd.Parameters. AddWithValue("T mprValue", TmprValue)
cmd.Parameters( "TmprValue").Db Type = DbType.Double
cmd.Parameters. AddWithValue("T mprRemark", TmprRemark)
cmd.Parameters( "TmprRemark").D bType = DbType.String
cmd.Parameters. AddWithValue("T mprLocationID", TmprLocationID)
cmd.Parameters( "TmprLocationID ").DbType = DbType.Int32
cmd.Parameters. AddWithValue("o riginal_TmprID" , original_TmprID )
cmd.Parameters( "original_TmprI D").DbType = DbType.Int32
cmd.Parameters. AddWithValue("o riginal_TmprNam e", original_TmprNa me)
cmd.Parameters( "original_TmprN ame").DbType = DbType.String
cmd.Parameters. AddWithValue("o riginal_TmprVal ue", original_TmprVa lue)
cmd.Parameters( "original_Tmprv alue").DbType = DbType.Double
cmd.Parameters. AddWithValue("o riginal_TmprRem ark",
original_TmprRe mark)
cmd.Parameters( "original_TmprR emark").DbType = DbType.String
cmd.Parameters. AddWithValue("o riginal_TmprLoc ationID",
original_TmprLo cationID)
cmd.Parameters( "original_TmprL ocationID").DbT ype = DbType.Int32
cmd.Connection. Open()
Try
cmd.ExecuteNonQ uery()
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 1587

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

Similar topics

1
6063
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
12921
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 = qdfs("qryInvoices") qdf.Parameters("prmInv") = strInvoice qdf.Parameters("prmCid") = lngCustomerID Set rst = db.OpenRecordset("qryInvoices")
2
1857
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 want to delete linked documents - but only if they are not linked to other entities outside of the category being deleted
1
1993
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, I just want to create an sql statement such as this: Dim SelectStatement As String = _ "SELECT folder_id, " & _ "document, " & _
11
3784
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 symbols insert without problem from query analyzer, so that suggests it's something within ASP.NET. I've tried using .NET textbox web controls as well as html textareas. I have a test database set up with 4 fields: varchar, nvarchar, text, and...
2
1481
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 client: http://www.opera.com/mail/
8
8044
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: WHERE LIKE '" & ASPvar & "' % ORDER BY ... However, my call is similar to: conn.qMyLookup strVar, rs
1
1960
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 the page are used to call itself with querystring values for brand, thinner, finish, etc. The page must show all colors if the querystring is empty and filter out records that don't match the querystring value when it's not. I've tried building...
3
2220
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 SQL that is being generated.
0
8316
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
8833
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...
1
8509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
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
6174
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
4168
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
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
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
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.