How to fill a Dataset with case sensitive primary keys using a OleDbDataAdapter

  • Thread starter Thread starter Monty M.
  • Start date Start date
M

Monty M.

Hello;

I was wondering if anyone can assist me with this problem. Here are
the tools I am using:

Language: C#
Database: MS SQL Server 2000
Application: Visual Studio 2005

1. I have a table whose primary key is a varchar data type.
-- Since this key is case-sensitive, these two IDs are unique:
asp_temp1
ASP_Temp1

2. I created a OleDbDataAdapter and generated a dataSet for this table
-- I receive an error stating that the constraints are not unique. The
errors pointed to the two rows above since it does not see a difference
between "asp_temp1" and "ASP_Temp1".


Does anyone know how to setup a DataAdapter to read case sensitive
data?

Thank you

Monty
 
Thank you for the help.

Now I have a different problem. I should have given more background
info to my problem. Here are the details.

-- I am using a strongly typed dataset. Therefore it contains
relationships, primary keys, etc.
-- I want to fill this dataset with data by looping through all of its
tables, creating a data adapter and filling the table with data from a
SQL Server database.
-- When I attempt to fill the data table, I get the following error:

"Cannot change CaseSensitive or Locale property. This change would lead
to at least one DataRelation or Constraint to have different Locale or
CaseSensitive settings between its related tables."

I know that if I set the EnforceConstraints property to false, I will
be able to get around this error. However I do not want to disable
constraints. Does anyone know how to disable the CaseSensitive
property for a relationship in a strongly typed dataset?

Thank you

Monty
 
Hi Monty,

I assume you're setting the DataTable.CaseSensitive property in code?

Open your DataSet in the XSD designer in Visual Studio, as usual. Open the
Properites window and select the DataSet from the component drop-down (or just
focus the empty area with the mouse, but not an object such as a table).
Switch CaseSensitive to false.

HTH
 
Hi Monty,

I just realized that it might work if you set CaseSensitive to true on all of
the DataTables (which you can do in the XSD designer as well) that reference
the table with the case-sensitive primary key, without having to enable the
property on the DataSet. I've never tried this myself though. If it doesn't
work you might want to create a special DataSet for that table and its related
tables so that you can preserve the case-sensitivity without having a negative
affect on the remaining tables in the DataSet that may require
case-insensitivity.
 
Back
Top