?
Solved

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

Posted on 2008-10-20
5
Medium Priority
?
504 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:UnderSeven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:UnderSeven
ID: 22762076
My code is actually erroring on the connection string.  
0
 

Author Comment

by:UnderSeven
ID: 22762255
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.  
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22764363
the error is self explanatory
you are trying to reference the system.data.dll from 2 places
one from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
and other from c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll

check and remove one of the references from your project
better one to be removed will be the c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\System.Data.SqlClient.dll
0
 

Author Closing Comment

by:UnderSeven
ID: 31507928
Thanks.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question