Karatas, FERHAT
I would love to change the world, but they won't give me the source code!
VS 2008 and .NET Framework 3.5 SP1
25.8.2008 10:56:50 - Filed under : C# | Asp.net | Ado.net
Microsoft .NET Framework 3.5 Service Pack 1
Microsoft .NET Framework 3.5 Service Pack 1 is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing updates to the .NET Framework 2.0 and .NET Framework 3.0 subcomponents.

Microsoft Visual Studio 2008 Service Pack 1
Improved WPF designers, SQL Server 2008 support, ADO.NET Entity Designer,Richer JavaScript support, enhanced AJAX and data tools, and Web site deployment improvements and so on.

For more details : http://msdn.microsoft.com/en-us/vstudio/products/cc533447.aspx

Keywords : Service Packs, VS 2008 SP1, .NET Framework SP1
with 0 comments

Using MissingSchemaAction.AddWithKey
25.1.2007 17:28:09 - Filed under : Ado.net
Adding schema information to a DataSet before filling it with data ensures that primary key constraints are included with the DataTable objects in the DataSet. As a result, when additional calls to fill the DataSet are made, the primary key column information is used to match new rows from the data source with current rows in each DataTable, and current data in the tables is overwritten with data from the data source.
Without the schema information, the new rows from the data source are appended to the DataSet, resulting in duplicate rows.

Example :
DataSet custDataSet = new DataSet();
custAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
custAdapter.Fill(custDataSet, "Customers");

Using FillSchema or setting the MissingSchemaAction to AddWithKey requires extra processing at the data source to determine primary key column information. This additional processing can hinder performance. If you know the primary key information at design time, we recommend that you explicitly specify the primary key column or columns in order to achieve optimal performance.

PS : You should use AddWithKey option if you want to handle "Constraint Exception". I use it in my little replication engine program like this ;

using (OracleCommand command = new OracleCommand())
    command.CommandText = "SELECT * FROM " + tableName + " WHERE " + primaryKeyField + "=" + drow[primaryKeyField];
    command.Connection = connection;

    adapter.SelectCommand = command;
    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

    DataTable dt = new DataTable();

    // Commandbuilder
    using (OracleCommandBuilder builder = new OracleCommandBuilder())
        builder.DataAdapter = adapter;

        // INSERT
        DataRow dr = dt.NewRow();
        foreach (DataColumn dc in dt.Columns)
            dr[dc.ColumnName] = drow[dc.ColumnName];


        catch (ConstraintException)
            // UPDATE
            DataRow row = dt.Rows[0];
            foreach (DataColumn dc in dt.Columns)
                row[dc.ColumnName] = drow[dc.ColumnName];

Related Terminology : MissingSchemaAction.AddWithKey, Primary Key, Constraint Exception
with 0 comments

Batch Updates in ADO.NET 2.0
30.8.2006 01:11:49 - Filed under : Ado.net
ADO.NET 2.0 has introduced the concept of Batch Updates, which allows you to designate the number of commands sent to the database at a given time.  If used correctly, this can increase the performance of your data access layer by reducing the number of roundtrips to the database.
When you updated a database using the DataAdapter in .NET 1.1 each command was sent to the database one at a time.  This caused a lot of roundtrips to the database.
The DataAdapter has an UpdateBatchSize Property that allows you to set the number of commands that will be sent to the database with each request.
  • UpdateBatchSize = 1, disables batch updates
  • UpdateBatchSize = X where X > 1, sends x statements to the database at a time
  • UpdateBatchSize = 0, sends the maximum number of statements at a time allowed by the server
using (OracleCommandBuilder cm = new OracleCommandBuilder(da))
  da.UpdateBatchSize = 0;
PS. Oracle supports this features in Oracle Data Provider for .NET Production

Related Terminology : Batch Update, ADO.NET 2.0, ODP.NET Release
with 0 comments

Memo field truncated
23.8.2006 06:38:41 - Filed under : Ado.net
In any Memo field that contains more than 1024 characters is truncated to 1024 characters when you insert some text to MS Access via web user interface.

Please check your dataset desinger file (ie. DatasetProducts.Designer.cs)
this._adapter.InsertCommand.Parameters.Add(new System.Data.OleDb.OleDbParameter("Content", System.Data.OleDb.OleDbType.WChar, 1024,
System.Data.ParameterDirection.Input, ((byte)(0)), ((byte)(0)),
"Content", System.Data.DataRowVersion.Current, false, null));
and replace 1024 to what you want (ie. 536870910)

Related Terminology : MS Access, TableAdapters, Insert Command, Update Command
with 0 comments

23.8.2006 05:38:58 - Filed under : Ado.net
System.ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.

This exception occurs if your lookup query does not return all the values that are used in the master-table. Some developers suggest that you enable referential integrity (ie, add a relation) in the database betweeen the lookup table and the master table; but this shouldnt prevent this scenario.

When I set "createConstraints" parameter to "false" then the error is disappeared.
ds.Relations.Add("myrelation", ds.Tables[0].Columns["ArticleID"], ds.Tables[1].Columns["ArticleID"],false);
Because, the exception is not related to Access. Remember the DataSet is disconnected and is independent from Access. This error can occur when a parent-child relationship is created and then children are loaded into the DataSet without the parent existing (whether or not the parent exists in the database is irrelevant - it has to exist in the DataSet as well because the DataSet is disconnected from the database)

Related Terminology : MS Access, Repeater, Dataset Relation
with 0 comments

Previous | Next
Current Page: 1