I kept getting an error when updating my DataGrid control. Below is my SQLDataSource and Datagrid control:
<asp:SqlDataSource ID="sqlLusHmoob" runat="server" ConnectionString="<%$ ConnectionStrings:LaujTsovConnectionString %>" DeleteCommand="DELETE FROM [lusHmoob] WHERE [wordID] = @wordID" InsertCommand="INSERT INTO [lusHmoob] ([wordID], [word], [whoInsert], [approval], [hmgTrans], [engTrans], [usage]) VALUES (@wordID, @word, @whoInsert, @approval, @hmgTrans, @engTrans, @usage)" SelectCommand="SELECT [wordID], [word], [whoInsert], [approval], [hmgTrans], [engTrans], [usage] FROM [lusHmoob]" UpdateCommand="UPDATE [lusHmoob] SET [word] = @word, [whoInsert] = @whoInsert, [approval] = @approval, [hmgTrans] = @hmgTrans, [engTrans] = @engTrans, [usage] = @usage WHERE [wordID] = @wordID"><DeleteParameters><asp:Parameter Name="wordID" Type="Object" /></DeleteParameters><InsertParameters><asp:Parameter Name="wordID" Type="Object" /><asp:Parameter Name="word" Type="String" /><asp:Parameter Name="whoInsert" Type="Object" /><asp:Parameter Name="approval" Type="Boolean" /><asp:Parameter Name="hmgTrans" Type="String" /><asp:Parameter Name="engTrans" Type="String" /><asp:Parameter Name="usage" Type="String" /></InsertParameters><UpdateParameters><asp:Parameter Name="word" Type="String" /><asp:Parameter Name="whoInsert" Type="Object" /><asp:Parameter Name="approval" Type="Boolean" /><asp:Parameter Name="hmgTrans" Type="String" /><asp:Parameter Name="engTrans" Type="String" /><asp:Parameter Name="usage" Type="String" /><asp:Parameter Name="wordID" Type="Object" /></UpdateParameters></asp:SqlDataSource><asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="wordID" DataSourceID="sqlLusHmoob"><Columns><asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /><asp:BoundField DataField="wordID" HeaderText="wordID" ReadOnly="True" SortExpression="wordID" /><asp:BoundField DataField="word" HeaderText="word" SortExpression="word" /><asp:BoundField DataField="whoInsert" HeaderText="whoInsert" SortExpression="whoInsert" /><asp:CheckBoxField DataField="approval" HeaderText="approval" SortExpression="approval" /><asp:BoundField DataField="hmgTrans" HeaderText="hmgTrans" SortExpression="hmgTrans" /><asp:BoundField DataField="engTrans" HeaderText="engTrans" SortExpression="engTrans" /><asp:BoundField DataField="usage" HeaderText="usage" SortExpression="usage" /></Columns></asp:GridView>
Here's the error:
Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |