Click here to Skip to main content
15,895,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Web Service not running Pin
dancelicious18-Apr-07 13:25
dancelicious18-Apr-07 13:25 
AnswerRe: C# Web Service not running Pin
mav.northwind18-Apr-07 10:30
mav.northwind18-Apr-07 10:30 
QuestionRe: C# Web Service not running Pin
dancelicious18-Apr-07 10:33
dancelicious18-Apr-07 10:33 
QuestionSelect TreeView Pin
mihksoft18-Apr-07 8:42
mihksoft18-Apr-07 8:42 
AnswerRe: Select TreeView Pin
dancelicious18-Apr-07 9:03
dancelicious18-Apr-07 9:03 
AnswerRe: Select TreeView Pin
Tarakeshwar Reddy18-Apr-07 10:15
professionalTarakeshwar Reddy18-Apr-07 10:15 
QuestionSend VB6 COM object To MSMQ from C# Pin
ABSD21341231212312318-Apr-07 8:24
ABSD21341231212312318-Apr-07 8:24 
Questionudf executing an sql statement Pin
Lordveralix18-Apr-07 8:13
Lordveralix18-Apr-07 8:13 
Hi!

I'm having a lot of difficulty in creating a user defined function in vs2005.

why I'm doing it in c# instead of vb or tsql is that I know C# better than the others (that and tsql won't let you make temp tables in functions

But as far as this goes, I can't seem to get this working.

I' trying to execute a simple select statement and get a datatable variable before I run it through the creative algorithm I have planned.

But I can't seem to get the data into a table.

I get this exception when I execute the function on the server:

System.InvalidOperationException: Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.


This is the code I use to get the data:

using(SqlConnection sqlcnct = new SqlConnection("Context Connection=true"))
{ SqlCommand sqlcmd = new SqlCommand(sqlstrng, sqlcnct);

sqlcnct.Open();
SqlDataReader sqldr = sqlcmd.ExecuteReader();

while (sqldr.Read())
{
//inserts into datatable here
}
}


But unfortunately SQL server 2005 doesn't like that.

Can anyone point me in the right direction or shoot down my hopes right here?

I'm trying to use a function to avoid having to run a sproc on every employee on the employee table and storing it in an actual field /table every time I need to run this function.


AnswerRe: udf executing an sql statement Pin
Not Active18-Apr-07 8:18
mentorNot Active18-Apr-07 8:18 
GeneralRe: udf executing an sql statement Pin
Lordveralix18-Apr-07 8:45
Lordveralix18-Apr-07 8:45 
Questionhow to manage "Security" tab in windows server 2003! Pin
Adeel Chaudhry18-Apr-07 8:13
Adeel Chaudhry18-Apr-07 8:13 
AnswerRe: how to manage "Security" tab in windows server 2003! Pin
kubben18-Apr-07 8:22
kubben18-Apr-07 8:22 
GeneralRe: how to manage "Security" tab in windows server 2003! Pin
Adeel Chaudhry18-Apr-07 8:28
Adeel Chaudhry18-Apr-07 8:28 
QuestionC# with crystal report XI : deploy problems Pin
Newbie_Toy18-Apr-07 8:12
Newbie_Toy18-Apr-07 8:12 
AnswerRe: C# with crystal report XI : deploy problems Pin
kubben18-Apr-07 8:27
kubben18-Apr-07 8:27 
AnswerRe: C# with crystal report XI : deploy problems Pin
Tarakeshwar Reddy18-Apr-07 10:17
professionalTarakeshwar Reddy18-Apr-07 10:17 
Questionsetup Pin
marwan_siala18-Apr-07 7:25
marwan_siala18-Apr-07 7:25 
AnswerRe: setup Pin
Obaid ur Rehman18-Apr-07 8:16
Obaid ur Rehman18-Apr-07 8:16 
GeneralRe: setup Pin
marwan_siala18-Apr-07 8:20
marwan_siala18-Apr-07 8:20 
AnswerRe: setup Pin
kubben18-Apr-07 8:28
kubben18-Apr-07 8:28 
GeneralRe: setup Pin
marwan_siala18-Apr-07 8:31
marwan_siala18-Apr-07 8:31 
QuestionWin Form & Web Form Control Update from a thread in Assembly Pin
zinc_z18-Apr-07 7:16
zinc_z18-Apr-07 7:16 
QuestionCreate/Open File options Pin
peterchen18-Apr-07 7:15
peterchen18-Apr-07 7:15 
AnswerRe: Create/Open File options Pin
Ed.Poore18-Apr-07 7:20
Ed.Poore18-Apr-07 7:20 
GeneralRe: Create/Open File options Pin
peterchen18-Apr-07 23:00
peterchen18-Apr-07 23:00 

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.