B
BenCoo
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">
</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: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>
<asparameter Name="TmprValue" Type="Double" />
<asparameter Name="TmprRemark" Type="String" />
<asparameter Name="TmprLocationID" Type="Int32" />
<asparameter Name="original_TmprID" Type="Int32" />
<asparameter Name="original_TmprName" Type="String" />
<asparameter Name="original_TmprValue" Type="Double" />
<asparameter Name="original_TmprRemark" Type="String" />
<asparameter 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_TmprLocationID",
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
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">
<ItemStyle HorizontalAlign="Center" Width="50px" />said:
</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" />
<ItemStyle HorizontalAlign="Center" />said:
</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>
<asparameter Name="TmprValue" Type="Double" />
<asparameter Name="TmprRemark" Type="String" />
<asparameter Name="TmprLocationID" Type="Int32" />
<asparameter Name="original_TmprID" Type="Int32" />
<asparameter Name="original_TmprName" Type="String" />
<asparameter Name="original_TmprValue" Type="Double" />
<asparameter Name="original_TmprRemark" Type="String" />
<asparameter 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_TmprLocationID",
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