Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 3587

Re: Extracting the C# ADO.NET drivers without installing

$
0
0

> 761887 ADO.NET:
> Provider throws exception when GetSchema() API is used in multi-threaded
application.

 

Yep - this was the fault we found.

 

I dont have the rights to log anything with SAP so I've passed across to those that access.

Hopefully they'll log the fault.

 

If they don't do it here's the test case

 

 

[TestFixture]

 

 

    class
BasicBCPTest

 

 

    {

 

 

      
[Test, Category("Unit"), Explicit("Writes to UCP")]

 

 

      
[TestCase(UBSDelta.DataAccess.Factory.AseInvariantName,
"uploads.connection.string")]

 

 

      
public void TestSimulatedPropertyBCP(string invariant, string
connectionStringKey)

 

 

      
{           

 

 

            var
random = new Random((int)DateTime.Now.Ticks);

 

 

          
var uploadId = random.Next(121212, 999999999);

 

 

 

 

 

          
var connectionString = ConfigurationManager.AppSettings[connectionStringKey];

 

 

 

 

 

          
Assert.IsFalse(string.IsNullOrEmpty(connectionString), "Failed to get DB
connection from key:" + connectionStringKey);

 

 

 

 

 

          
var factory = UBSDelta.DataAccess.Factory.Create(invariant);

 

 

 

 

 

          
using (var connection =
factory.GetConnection(connectionString).AndOpen())          

 

 

            using
(var bcp = factory.CreateBulkCopy(connection))

 

 

          
{

 

 

              
Assert.IsNotNull(connection, "Failed to create connection");

 

 

              
Assert.IsNotNull(bcp, "Failed to create bcp");

 

 

              

 

 

                var
tableName = "CDUpload..UCP";

 

 

 

 

 

              
var sourceTable = new DataTable();

 

 

              
sourceTable.Clear();

 

 

              
sourceTable.Columns.Add("UploadId", typeof(int));

 

 

              
sourceTable.Columns.Add("BlockId", typeof(Int16));

 

 

   
           sourceTable.Columns.Add("Line",
typeof(int));

 

 

              
sourceTable.Columns.Add("PropertyId", typeof(int));

 

 

              
sourceTable.Columns.Add("PropertyDate", typeof(DateTime));

 

 

              
sourceTable.Columns.Add("ErrorStatus", typeof(ulong));

 

 

              
sourceTable.Columns.Add("PropertyValue", typeof(string));

 

 

              

 

 

               

 

 

                var
row1 = sourceTable.NewRow();

 

 

              
row1["UploadId"] = uploadId;

 

 

              
row1["BlockId"] = 1;

 

 

              
row1["Line"] =
3;              

 

 

                row1["PropertyId"]
= 12345;

 

 

              
row1["PropertyDate"] = DBNull.Value;  

 

 

                row1["PropertyValue"]
= "wibble";

 

 

              
row1["ErrorStatus"] = 0;

 

 

              

 

 

                sourceTable.Rows.Add(row1);

 

 

 

 

 

              
bcp.DestinationTableName = tableName;

 

 

 

 

 

              
using (var reader = sourceTable.CreateDataReader())

 

 

              
{

 

 

                  
try

 

 

                  
{

 

 

                      
bcp.WriteToServer(reader);

 

 

                  
}

 

 

                  
catch (Exception e)

 

 

                  
{

 

 

                      
Assert.Fail("Got DB exception" + e.Message + "\n" +
e.StackTrace);

 

 

                  
}

 

 

      
        }

 

 

 

 

 

              
// Now pull back BCP'd values and lets see if they are the same

 

 

              
var command = connection.CreateCommand();

 

 

 

 

 

              
command.CommandText = "Select * from " + tableName + " where
UploadId=" + uploadId;

 

 

 

 

 

   
           using (var
reader = command.ExecuteReader())

 

 

              
{

 

 

                  
Assert.IsNotNull(reader, "Failed to read rows back! after BCP");

 

 

 

 

 

                  
var nbrRows = 0;

 

 

                  
while (reader.Read())

 

 

               
   {

 

 

                      
var readUploadId = reader.Get<int>("UploadId");

 

 

                      
var value = reader.Get<string>("PropertyValue");

 

 

 

 

 

                      
Assert.IsTrue(readUploadId == uploadId, "Unexpected uploadId");

 

 

                      
Assert.IsTrue(value == "wibble", "Expected wibble in
PropertyValue");

 

 

 

 

 

                      
nbrRows++;

 

 

                  
}

 

 

                  
Assert.IsTrue(nbrRows == 1, "Failed to get BCP rows back!");

 

 

              
}

 

 

 

 

 

  
            //
Cleanup temp UploadId entries

 

 

              
command.CommandText = "delete from " + tableName + " where
UploadId=" + uploadId;

 

 

              
command.ExecuteNonQuery();

 

 

          
}

 

 

      
}

 

 

    }


Viewing all articles
Browse latest Browse all 3587

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>