Domanda

Il trasferimento MSSQL Applicazione per Sybase ASE (15.0), e di risolvere il problema quando chiamo GetDeleteCommand. L'errore riportato è il seguente:

generazione SQL dinamica per DeleteCommand non è supportata contro un SelectCommand che non restituisce alcuna informazione colonna chiave.

Il problema si verifica solo per tabella temporanea, tavolo non temporanea identico funziona bene. Tabella contiene una chiave primaria.

Riprodotto con il programma di test di seguito.



    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);
                }
            }
        }
    }


È stato utile?

Soluzione 2

Contacted Sybase support, turns out I had to update some system stored procedures. There is a folder that ends with "oledb\sp", and I had to run a .bat file from the folder. I got the latest ebf and ran the batch file install_oledb_sprocs.bat, the problem went away. Worth mentioning, that sybase 15.5 did not have the issue without patching.

P.S. Thank you to 'aF' for your time looking into the issue.

Altri suggerimenti

In the select statement, instead of * use the column names.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top