473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

I set my database to trustworthy and deployed this clr stored proc as unsafe ok but when i run this it returns 1 each time. as if ival keeps getting set back to 0 each time i call this clr stored proc. How to fix so that ival keeps its current value

DR
I set my database to trustworthy and deployed this clr stored proc as unsafe
ok but when i run this it returns 1 each time. as if ival keeps getting set
back to 0 each time i call this clr stored proc. How to fix so that ival
keeps its current value each time i execute this from sql server?
public partial class UserDefinedFunctions
{
static long ival = 0;
[Microsoft.SqlServer.Server.SqlFunction]
public static long GetTimestampF()
{
return ++ival;
}
};
Oct 29 '07 #1
3 1198
On 2007-10-29 16:17:48 -0700, "DR" <so*******************@yahoo.comsaid:
I set my database to trustworthy and deployed this clr stored proc as unsafe
ok but when i run this it returns 1 each time. as if ival keeps getting set
back to 0 each time i call this clr stored proc. How to fix so that ival
keeps its current value each time i execute this from sql server?
I don't know the answer to your question, but I would like to ask you
to figure out what about the way you are posting causes your subject
header to wind up being the first N characters of your post, and stop
doing that.

I know that Outlook Express doesn't do that by default. The only way I
can think of that might be causing that is for you to copy and paste
your post into the Subject field. But it's hard for me to understand
what might prompt someone to do such a thing, rather than just writing
a nice, topical, descriptive Subject field.

However it's happening, it would be wonderful if you could make it stop.

Thanks,
Pete

Oct 29 '07 #2
"DR" <so*******************@yahoo.comwrote in message
news:uv**************@TK2MSFTNGP06.phx.gbl...
>I set my database to trustworthy and deployed this clr stored proc as
unsafe ok but when i run this it returns 1 each time. as if ival keeps
getting set back to 0 each time i call this clr stored proc. How to fix so
that ival keeps its current value each time i execute this from sql server?
public partial class UserDefinedFunctions
{
static long ival = 0;
[Microsoft.SqlServer.Server.SqlFunction]
public static long GetTimestampF()
{
return ++ival;
}
};

Should work, works for me, are you sure you have deployed this code?.

Willy.

Oct 30 '07 #3
A minor aside for when you /do/ get it working... you might want to
watch out for threading. A simple fix would be:

return Interlocked.Increment(ref ival);

However, I don't know about the specific problem here; one thought -
it isn't shown in your snippet, but have you set IsDeterministic to
true in the SqlFunctionAttribute? This may (obviously) cause it to be
cached at the SQL end (since the non-existant parameters will always
match).

Marc
Oct 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Wolfgang Kreuzer | last post by:
Try hard to become familiar with T-SQL. Can anybodey tell me the best way to deal with set's provided by a stored procedure. Til yesterday I thougt trapping set in temp table using INSERT EXEC...
1
by: Eric Land | last post by:
Help! I'm trying to call a parameterized stored proc in ASP.NET in VB. I am creating a command object and creating a parametr list, and assigning a value from a session variable (this is working)...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
4
by: daz_oldham | last post by:
Hi All I am trying to execute a stored procedure that does a very simple lookup and returns a text field. However, when I try to execute it, I am getting a rather strange error that I can't seem...
3
by: .Net Sports | last post by:
I need to call an stored procedure from an asp script, I don't need to do an Output parameter, only input parameters on 3 vars, but I get a "BOF EOF not true or record has been deleted" error when...
8
by: colmkav | last post by:
Can someone tell me how I can access the return value of a function called from Oracle as opposed to a store proc from oracle? my oracle function is get_num_dates_varposfile. I am only used to...
0
by: DR | last post by:
I set my database to trustworthy and deployed this clr stored proc as unsafe ok but when i run this it returns 1 each time. as if ival keeps getting set back to 0 each time i call this clr stored...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query b) .SQL property of querydef is a string, the...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.