Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

CLR ODBC Call Hangs Expand / Collapse
Author
Message
Posted Tuesday, July 9, 2013 1:18 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, December 5, 2014 4:07 AM
Points: 13, Visits: 161
Hi,

we have developed a .NET method which we have incorportaed in SQL Server as an assembley, and wrapped it in a stored procedure. NOTE.. The method has a try.. catch which raises the exception. The stored procedure wrapper also has a try catch which returns the error in a controlled fashion.

The .NET method interacts with an IBM AS400 database using ODBC.

On the server we have an instance of SQL 2008 R2 and SQL 2005. When we call the assembley from SQL 2005 it works, however, when we run from the SQL 2008 R2 instance, it hangs, and never returns.

We have tried the same thing on other servers which have SQL 2008 R2 installed, and they work.

From this I would conclude that it is something to do with the implementation of SQL Server 2008 R2 on the server.

Has anyone experienced any similar issues to this, or does anyione have any idea of what may be causing the process to hang? Below is a copy of the .NET code...


/***********************************************************************************************\
* Class name: ExecuteNonQuery
* Author: Neil Bryan
* Date: 2013-07-03
* Description: CLR functionality for executing an update, delete or insert on the DBS
* system from SQL Server. Note: Connection details are hard coded.
* Amendment History:
*
* Who Date Ref Description
* --- ---- --- -----------
* Neil Bryan 2013-07-03 Created.
\***********************************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Odbc;
using Microsoft.SqlServer.Server;


namespace DBS_CLR
{
public class FunctionLibrary
{
public static void ExecuteNonQuery(string sql)
{
OdbcConnection conn = new OdbcConnection();
OdbcCommand myOdbcCommand = new OdbcCommand(sql);
conn.ConnectionTimeout = 10;
myOdbcCommand.Connection = conn;
conn.ConnectionString = "Dsn=dsnname;uid=uname;pwd=pword";
try
{
conn.Open();
myOdbcCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
throw (ex);
}
finally
{
myOdbcCommand.Connection.Close();
conn.Close();
}
}

}
}




many thanks,

Neil
Post #1471455
Posted Wednesday, August 21, 2013 1:16 PM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Thursday, December 11, 2014 12:22 PM
Points: 1,444, Visits: 3,232
I assume you have tested the ODBC connection manually with the ODBC applet? Make sure that the service account that the instance is running as has permission on the DSN you created.




The probability of survival is inversely proportional to the angle of arrival.
Post #1486888
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse