Question

MSSQL Application à Porting Sybase (ASE 15.0), et rencontrez un problème quand je l'appelle GetDeleteCommand. L'erreur signalée est:

Génération dynamique SQL pour la DeleteCommand est pas pris en charge contre un SelectCommand qui ne renvoie pas d'informations de colonne clé.

Le problème se produit uniquement pour la table temporaire, fonctionne identique table non temporaire bien. Le tableau contient une clé primaire.

Reproduit en utilisant le programme de test ci-dessous.



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.OleDb;
    using System.Data;

    namespace DataAdapterTempTable
    {
        class Program
        {
            static void Main(string[] args)
            {
                String ConnectionString = "Provider=ASEOLEDB;Data Source=devsun3:5003;Initial Catalog=ctc;User ID=aigtac12;Password=aigtac12;"; // sybase connection string
                //String ConnectionString = "Provider=SQLOLEDB;Data Source=fiji;Persist Security Info=False;Initial Catalog=nxgn0811;Integrated Security=SSPI"; // mssql connection string

                String TableName = "#alex_temporary_table_test"; // does not work for sybase
                //String TableName = "alex_real_table_test"; // works for sybase + mssql

                String CreateStatement = "create table " + TableName + " (currency_id varchar(4) primary key, rate  decimal(25,6), format   char(1))";

                String SelectStatement = "select * from " + TableName;

                try
                {
                    OleDbConnection con = null;
                    con = new OleDbConnection(ConnectionString);
                    con.Open();

                    OleDbCommand cmd = con.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = CreateStatement;
                    int count = cmd.ExecuteNonQuery();

                    OleDbCommand cm1 = con.CreateCommand();
                    cm1.CommandType = CommandType.Text;
                    cm1.CommandText = SelectStatement;
                    OleDbDataAdapter DA2 = new OleDbDataAdapter(cm1);
                    DataTable DT2 = new DataTable();
                    DA2.FillSchema(DT2, SchemaType.Mapped);
                    OleDbCommandBuilder cmdbldr = new OleDbCommandBuilder(DA2);
                    DA2.InsertCommand = cmdbldr.GetInsertCommand();

                    DA2.DeleteCommand = cmdbldr.GetDeleteCommand(); // this line fails in sybase for temporary table

                    DA2.UpdateCommand = cmdbldr.GetUpdateCommand();
                    DA2.Fill(DT2);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
    }


Était-ce utile?

La solution 2

Contacté support Sybase, se avère que je devais mettre à jour des procédures stockées système. Il y a un dossier qui se termine par « oledb \ sp », et je devais exécuter un fichier .bat à partir du dossier. Je suis la dernière EBF et a couru le fichier batch install_oledb_sprocs.bat, le problème a disparu. Il convient de mentionner que SYBASE 15,5 n'a pas eu le problème sans patcher.

P.S. Merci à 'aF' pour votre temps à regarder la question.

Autres conseils

Dans l'instruction select, au lieu de * utiliser les noms de colonnes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top