Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


CLR ODBC Call Hangs


CLR ODBC Call Hangs

Author
Message
mr.neil.bryan
mr.neil.bryan
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 324
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
sturner
sturner
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1473 Visits: 3254
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search