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.
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";
}
}
ASKER
My code is actually erroring on the connection string.
ASKER
I am getting this error
Error 1 The type 'System.Data.SqlClient.Sql Connection ' exists in both 'c:\WINDOWS\Microsoft.NET\ Framework\ v2.0.50727 \System.Da ta.dll' and 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemb lies\Syste m.Data.Sql Client.dll ' H:\My Documents\Visual Studio 2005\Projects\tat_io_sched uler\tat_i o_schedule r\CodeFile 1.cs 16 9 tat_io_scheduler
I don't see why, the two libraries it is complaining about are both necessary.
Error 1 The type 'System.Data.SqlClient.Sql
I don't see why, the two libraries it is complaining about are both necessary.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
http://en.csharp-online.net/In-Process_Data_Access_in_SQL_Server_2005SqlTriggerContext
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.server.sqltriggercontext.aspx
http://www.15seconds.com/issue/041006.htm