Link to home
Start Free TrialLog in
Avatar of UnderSeven
UnderSeven

asked on

Trying to make a connection in C# to a SQLserver db for a CLR trigger

I have more or less borrowed the code that is supposed to make this possible, but it isn't working.  I appaer to by misusing the SQLconnection class.  I've done this before in vb but obviously c# is a little different.  Here is the code I am currently trying to use.

Any help pointing me toward the right direction woudl be appreciated.
using System;
 
using System.Data;
using System.Data.Sql;
using Microsoft.SqlServer.Server;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Xml;
 
 
public class tat_io_trigger
{
    public static void Main()
    {
        SqlTriggerContext triggContext = SqlContext.TriggerContext;
        Sqlconnection conn = new SqlConnection ("context connection = true");
        conn.open();
        SqlCommand sqlComm = conn.CreateCommand();
        SqlPipe sqlP = SqlContext.Pipe;
        SqlDataReader dr;
            sqlComm.CommandText = "Exec sp_gettatdata";
 
 
    }
}

Open in new window

Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Avatar of UnderSeven
UnderSeven

ASKER

My code is actually erroring on the connection string.  
I am getting this error

Error      1      The type 'System.Data.SqlClient.SqlConnection' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll' and 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll'      H:\My Documents\Visual Studio 2005\Projects\tat_io_scheduler\tat_io_scheduler\CodeFile1.cs      16      9      tat_io_scheduler


I don't see why, the two libraries it is complaining about are both necessary.  
ASKER CERTIFIED SOLUTION
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.