Click here to Skip to main content
15,904,652 members
Home / Discussions / C#
   

C#

 
QuestionC# and C++ Pin
netJP12L18-Apr-07 10:31
netJP12L18-Apr-07 10:31 
AnswerRe: C# and C++ Pin
Christian Graus18-Apr-07 10:45
protectorChristian Graus18-Apr-07 10:45 
AnswerRe: C# and C++ Pin
pbraun18-Apr-07 14:58
pbraun18-Apr-07 14:58 
GeneralRe: C# and C++ Pin
Christian Graus18-Apr-07 16:06
protectorChristian Graus18-Apr-07 16:06 
GeneralRe: C# and C++ Pin
netJP12L18-Apr-07 16:19
netJP12L18-Apr-07 16:19 
GeneralRe: C# and C++ Pin
pbraun18-Apr-07 18:07
pbraun18-Apr-07 18:07 
QuestionC# Web Service not running Pin
dancelicious18-Apr-07 9:02
dancelicious18-Apr-07 9:02 
AnswerRe: C# Web Service not running Pin
_mubashir18-Apr-07 9:34
_mubashir18-Apr-07 9:34 
GeneralRe: C# Web Service not running Pin
dancelicious18-Apr-07 9:42
dancelicious18-Apr-07 9:42 
GeneralRe: C# Web Service not running Pin
dancelicious18-Apr-07 9:49
dancelicious18-Apr-07 9:49 
GeneralRe: C# Web Service not running Pin
kubben18-Apr-07 9:53
kubben18-Apr-07 9:53 
GeneralRe: C# Web Service not running Pin
dancelicious18-Apr-07 10:02
dancelicious18-Apr-07 10:02 
GeneralRe: C# Web Service not running Pin
kubben18-Apr-07 10:04
kubben18-Apr-07 10:04 
GeneralRe: C# Web Service not running Pin
dancelicious18-Apr-07 10:11
dancelicious18-Apr-07 10:11 
GeneralRe: C# Web Service not running Pin
kubben18-Apr-07 12:52
kubben18-Apr-07 12:52 
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 

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.