This is a migrated thread and some comments may be shown as answers.

Unable to update db with griddropdowncolumn

6 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 19 Aug 2008, 08:57 AM

Hello!

I've used "Business Grid demo" to build my own sample app from.
I have a setup with main table, .persons (access db) containing names and ID for their workingplace and a table, .workingplace containing the names of the workingplace.
When i try to update the form a get an OleDbException error. "Data type mismatch in criteria expression".
I have been trying for days to solve this probably easy error but without any luck. Hope somebody can help me out here.
I'm running the app with ASP.NET-version:2.0.50727.3053  and Telerik RadGrid.Net2.dll ver 5.0.1.0

Regards

Janne P

Here's my code:

The Grid:

<

radG:RadGrid ID="DetailsGrid" runat="server" AutoGenerateColumns="False" GridLines="None" DataSourceID="ds_details" EnableAJAXLoadingTemplate="True" LoadingTemplateTransparency="15" ShowHeader="False" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" EnableAJAX="True" OnItemInserted="DetailsGrid_ItemInserted" OnItemUpdated="DetailsGrid_ItemUpdated" OnPreRender="DetailsGrid_PreRender" OnCancelCommand="DetailsGrid_CancelCommand" OnItemCreated="DetailsGrid_ItemCreated" OnInsertCommand="DetailsGrid_InsertCommand" Width="464px" Style="overflow: hidden;">

<MasterTableView DataSourceID="ds_details" DataKeyNames="fldInstId" Width="219px">
<Columns>
<radG:GridBoundColumn DataField="fldIdNr" HeaderText="IdNr" UniqueName="fldIdNr" ColumnEditorID="TextEditor" />

<radG:GridBoundColumn DataField="fldFnamn" HeaderText="Förnamn" UniqueName="fldFnamn" ColumnEditorID="TextEditor" />

<radG:GridBoundColumn DataField="fldEnamn" HeaderText="Efternamn" UniqueName="fldEnamn" ColumnEditorID="TextEditor" />

<radG:GridDropDownColumn DataField="fldInstId" ListTextField="fldNamn" ListValueField="fldIdNr"ColumnEditorID="DropDownEditor1" DataSourceID="ds_arbetsplats" HeaderText="Arbetsplats" UniqueName="fldInstId" DataType="System.Int32" />

<radG:GridBoundColumn DataField="fldTitle" HeaderText="Titel" UniqueName="fldTitle" ColumnEditorID="TextEditor"/>
</Columns>
</MasterTableView>

</radG:RadGrid>

The data source for the grid:

<

asp:SqlDataSource ID="ds_details" runat="server"
ConnectionString="<%$ ConnectionStrings:conn_clients %>"
DeleteCommand="DELETE FROM [tblDr] WHERE [fldIdNr] = ?" InsertCommand="INSERT INTO [tdlDr] ([fldFnamn], [fldEnamn]) VALUES (?, ?)" ProviderName="<%$ ConnectionStrings:conn_clients.ProviderName %>" SelectCommand="SELECT fldIdNr, fldFnamn, fldEnamn, fldInstId, fldTitle FROM tblDr WHERE (fldIdNr = ?)"
UpdateCommand="UPDATE tblDr SET fldFnamn = ?, fldEnamn = ?, fldInstId = ?, fldTitle = ? WHERE (fldIdNr = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="BusinessGrid" DefaultValue="" Name="fldIdNr" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="fldFnamn" Type="String" />
<asp:Parameter Name="fldEnamn" Type="String" />
<asp:Parameter Name="fldInstId" Type="Int16" />
<asp:Parameter Name="fldTitle" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="fldFnamn" Type="String" />
<asp:Parameter Name="fldEnamn" Type="String" />
</InsertParameters>
<DeleteParameters>
<asp:Parameter Name="fldIdNr" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>

 Data source for the dropdowncolumn:

<asp:SqlDataSource ID="ds_arbetsplats" runat="server"
ConnectionString="<%$ ConnectionStrings:conn_clients %>"
ProviderName="<%$ ConnectionStrings:conn_clients.ProviderName %>" SelectCommand="SELECT [fldIdNr], [fldNamn] FROM [tblInstitutioner]">
</asp:SqlDataSource>

6 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 22 Aug 2008, 07:53 AM
Hi Jan,

Please ensure that the fields specified through the DataField/ListValueField properties of the GridDropDownColumn are of the same data type and the entries have a precise match.

Find more information on how to configure GridDropDownColumn here.

Let us know if you need further help.

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jan
Top achievements
Rank 1
answered on 25 Aug 2008, 07:12 AM
Thank you Iana for your reply!
I've checked the data types and DataField/ListValueField are both Long Integer and ListValueField are autonumber and primary key. The DataField is number - Long Integer.

Regards

Janne P
0
Sebastian
Telerik team
answered on 27 Aug 2008, 10:52 AM
Hello Jan,

Since you enabled automatic updates/inserts for your grid instance, can you please use the approach presented here (subscribing to the ItemUpdated/ItemInserted events of the grid) to troubleshoot your case and designate the exact reason for the data type mismatch? This can help us track down the cause of the erroneous behavior to address it accordingly.

Alternatively, listen for the Updating/Inserting events of the ds_details SqlDataSource control in order to verify when the exception is produced at data source level. I hope these directions are helpful.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jan
Top achievements
Rank 1
answered on 08 Sep 2008, 08:27 AM
Thanks Stephen for your reply!
I'm sorry for my late reply but I had to work elsewhere....
I did try the errer handling code described in the article but all I get is the same error message as before: "Data type mismatch in criteria expression".
If I run the sql statement directly in VWD 2008 or in Access it works just fine.
Please let me know if you have any more ideas how to troubleshoot.

Regards

Janne P
0
Iana Tsolova
Telerik team
answered on 08 Sep 2008, 01:32 PM
Hi Jan,

Could you please send us a sample project reproducing the unexpected behavior? Thus we could debug it locally in order to get to the source of it and find a resolution.

Let us know how it goes.

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jan
Top achievements
Rank 1
answered on 09 Sep 2008, 07:25 AM
I've sent you the project via e-mail: support@telerik.com
Thank you.

Regards

Janne P
Tags
Grid
Asked by
Jan
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Jan
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or