Click here to Skip to main content
15,915,508 members
Home / Discussions / C#
   

C#

 
QuestionDirectX in C# Pin
legolass26-Jul-07 21:36
legolass26-Jul-07 21:36 
AnswerRe: DirectX in C# Pin
Christian Graus26-Jul-07 21:40
protectorChristian Graus26-Jul-07 21:40 
QuestionSome Basic Question Related To Image Processing…(C# .Net) Pin
zeeShan anSari26-Jul-07 21:30
zeeShan anSari26-Jul-07 21:30 
AnswerRe: Some Basic Question Related To Image Processing…(C# .Net) Pin
Christian Graus26-Jul-07 21:42
protectorChristian Graus26-Jul-07 21:42 
QuestionHow to convert Struct to array Pin
Morad Kobi26-Jul-07 21:30
Morad Kobi26-Jul-07 21:30 
AnswerRe: How to convert Struct to array Pin
Malcolm Smart26-Jul-07 21:35
Malcolm Smart26-Jul-07 21:35 
AnswerRe: How to convert Struct to array Pin
Christian Graus26-Jul-07 21:38
protectorChristian Graus26-Jul-07 21:38 
QuestionCLR-Trigger coded in c# (Express Edition 2005) Pin
jacklynn_mei26-Jul-07 21:25
jacklynn_mei26-Jul-07 21:25 
Hi...Smile | :)
I am newbie in c#, please help me on clr trigger.
I have done a clr trigger and everytime i debug my c# code,an error occured on this part
AIClass.AICheck.checkUserRole();


The error description is like this :->
InvalidOperationException was Unhandled
The requested operation requires a SqlClr context, which is only available when running in the Sql Server process.


I dont know what to do...
And I cannot create a trigger inside Sql Server Express Edition 2005. I did like this:->
create trigger tgAI
on AIEvent
for insert
as
external name
AIAssembly.AIClass.userRoleCheck


and the error appeared:-> Msg 6505, Level 16, State 1, Procedure tgAI, Line 1
Could not find Type 'AIClass' in assembly 'AIClass'.


my code in c# is like this (will be called in the main class in console App.):->
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Server;
using System.Data;
using System.Data.SqlClient;

namespace AIClass
{
public class AICheck
{
//[SqlTrigger(Event = "FOR INSERT", Name = "AI_tg", Target = "AIEvent")]
public static void checkUserRole()
{
SqlTriggerContext tgContext = SqlContext.TriggerContext;
//SqlConnection conn = new SqlConnection("Data Source=DIMENSION3000\\SQLEXPRESS; Initial Catalog=AITania; User Id=sa; Password=123456");
using (SqlConnection conn = new SqlConnection("context connection=true"))
conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlDataReader reader;
string msg = "";

if (tgContext.TriggerAction == TriggerAction.Insert)
{

//SqlCommand sqlComm = new SqlCommand();
//SqlPipe sqlPipe = SqlContext.Pipe;
cmd.CommandText = "SELECT * FROM INSERTED";
reader = cmd.ExecuteReader();
//sqlComm.Connection = conn;
//sqlComm.CommandText = "SELECT * FROM INSERTED";

//for (int x = 0; x < tgContext.ColumnCount; ++x)
//{
// msg += string.Format("Column {0} {1} been updated{2}", x, (tgContext.IsUpdatedColumn(x) ? "has" : "has not"), Environment.NewLine);
//}
for (int i = 0; i < reader.FieldCount;i++ )
{
msg = msg + reader.GetName(i) + ":" + (string)reader[i] + " ";
}
}conn.Close();

}
}
}


Please help me..

thanks..
-jack-
AnswerRe: CLR-Trigger coded in c# (Express Edition 2005) Pin
leppie27-Jul-07 3:21
leppie27-Jul-07 3:21 
QuestionRe: CLR-Trigger coded in c# (Express Edition 2005) Pin
jacklynn_mei29-Jul-07 16:22
jacklynn_mei29-Jul-07 16:22 
QuestionAnonymous methods Pin
Michael Sync26-Jul-07 21:24
Michael Sync26-Jul-07 21:24 
AnswerRe: Anonymous methods Pin
Christian Graus26-Jul-07 21:33
protectorChristian Graus26-Jul-07 21:33 
GeneralRe: Anonymous methods Pin
Malcolm Smart26-Jul-07 21:37
Malcolm Smart26-Jul-07 21:37 
GeneralRe: Anonymous methods Pin
Christian Graus26-Jul-07 21:39
protectorChristian Graus26-Jul-07 21:39 
GeneralRe: Anonymous methods Pin
Malcolm Smart26-Jul-07 21:51
Malcolm Smart26-Jul-07 21:51 
GeneralRe: Anonymous methods Pin
Christian Graus26-Jul-07 22:01
protectorChristian Graus26-Jul-07 22:01 
AnswerRe: Anonymous methods Pin
szukuro26-Jul-07 21:51
szukuro26-Jul-07 21:51 
GeneralRe: Anonymous methods Pin
J4amieC26-Jul-07 22:07
J4amieC26-Jul-07 22:07 
GeneralRe: Anonymous methods Pin
Kevin McFarlane26-Jul-07 23:46
Kevin McFarlane26-Jul-07 23:46 
GeneralRe: Anonymous methods Pin
Michael Sync26-Jul-07 23:47
Michael Sync26-Jul-07 23:47 
GeneralRe: Anonymous methods Pin
szukuro27-Jul-07 1:06
szukuro27-Jul-07 1:06 
GeneralRe: Anonymous methods Pin
Michael Sync27-Jul-07 1:29
Michael Sync27-Jul-07 1:29 
AnswerRe: Anonymous methods Pin
leppie27-Jul-07 3:22
leppie27-Jul-07 3:22 
Questionstring array Pin
Xmen Real 26-Jul-07 20:52
professional Xmen Real 26-Jul-07 20:52 
AnswerRe: string array Pin
Urs Enzler26-Jul-07 20:54
Urs Enzler26-Jul-07 20:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.