Showing posts with label net. Show all posts
Showing posts with label net. Show all posts

Tuesday, March 20, 2012

[VB.NET2003] DataControl with MDI

hello,..

Inof: using VB.NET 2003 ADO provider - My Database MS Access2003

i want just simple code of how to add Datacontrol on MDI Parent and control this Datacontrol for each MDIChild?

like if i have these Datacontrol [ Add, Save, Delete, Update, Edit, Print] was installed in MDI Parent with Toolbar and you can by these Datacontrols to control each MDI Child form?

also i have in each MDI Child Form Tabcontrol how to programme this code as you see in my link picture

http://img502.imageshack.us/img502/1...controlsw3.jpg

You will most likely get the help you seek by posting the question to one of the VB.NET Form related forums, or one of the VB.NET or Access related NNTP newsgroups.sql

Monday, March 19, 2012

[SQL Server]Login failed for user

I am using Crystal Reports, VB.net, SQL Server 2000sp3, MDAC 8.0, and Windows XP. When I try to make a connection from a Crystal Report to SQL Server via an ODBC connection, I get the following message:

Details: 28000:[Microsoft][SQL Server Driver][SQL Server]Login failed for user domain/username

In the odbc, I specify SQL Server authentication and provide a username and password but these are being ignored. Why is Windows authentication being used in place of the SQL Server authentication that I specify in my odbc?

Thanks in advance,

MattThat's Crystal for you :)|||What version of Crystal Reports are you using?|||Originally posted by awsterling
What version of Crystal Reports are you using?

I am the version that came with Visual Studio .Net 2003. I don't know how to get the version number from it.

Thanks.|||Get ActiveReport from DataDynamics and you won't have to deal with these issues any more :)

Thursday, March 8, 2012

[Performance Discussion] To schedule a time for mssql command, which way would be faster a

1. Use mssql server agent service to take the schedule
2. Use a .NET windows service with timers to call SqlClientConnection

above, which way would be faster and get a better performance?I don't think you'll see any performance difference.

but go with agent.|||ok, but will have a difference when busy

[OTP] Multi User Application Database Transaction Stability

I am currently developing a multi user VB.NET 2005 application and this is my first time to involve in multi user application. Anyway, i know that multi-user application is not as easy as standalone application. I need to take care of the database stability for each and every user. My concern is may i know how to build up this stability for each and every transaction in terms of Data insert and update? This database resides on server and the user is able to access the data through the client application.

INSERT

The primary key is generated by application when the user enters into the data insert screen and it is done by counting the total amount of records in database. If two users perform insert at the same time, may i know how to deal with these primary keys? I am sure my application must be able to generate two different primary keys for these two users based on the time gap e.g. 0.001 milli second for the first user who enters into the screen and occupy the first primary key than the second user. But i have no idea on how to translate this to code.

UPDATE

If a particular record is viewed by a user and that user peforms an updates on the record while another user updates it at the same time, i may need to figure out a solution for this else the database will really be crashed. Is there any suggestion on it? May i know how to implement lock and unlock the record? Thank you.

For the INSERT part, you can't really generate keys like that from the client side without locking the entire table on the server. You can look at use of IDENTITY column for example which allows you to generate sequential numbers on the server. The server handles the concurrency part. There are other ways to generate keys on the client like using GUID for example. But all of these depends on the type of application you are writing and your data model.

For the UPDATE part, when one connection is updating a particular row or rows then any other connection that tries to update the same row(s) will be blocked. So the concurrent updates will happen in serial fashion depending on which ran first.

My suggestion would be to look at some of the topics on concurrency, locking, transactions in Books Online to get an idea of what the database engine can do. You should also get a book on SQL Server that describes some of these concepts so you don't try to invent or reinvent elaborate techniques on the client which might be suspect at best.

[OT] User-Defined string Functions MS SQL Server 2005 Transact-SQL SQLCLR .Net

User-Defined string Functions MS SQL Server 2005 Transact-SQL SQLCLR (VB. Net, C#.Net, C++. Net)

Ladies and Gentlemen,

I am pleased to offer, free of charge, the following string functions MS SQL Server 2005 Transact-SQL SQLCLR (VB. Net, C#.Net, C++. Net):

AT(): Returns the beginning numeric position of the nth occurrence of a character expression within another character expression, counting from the leftmost character.
RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string.
OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
PADL(): Returns a string from an expression, padded with spaces or characters to a specified length on the left side.
PADR(): Returns a string from an expression, padded with spaces or characters to a specified length on the right side.
PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
CHRTRAN(): Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.
STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
STRFILTER(): Removes all characters from a string except those specified.
GETWORDCOUNT(): Counts the words in a string.
GETWORDNUM(): Returns a specified word from a string.
GETALLWORDS(): Inserts the words from a string into the table.
PROPER(): Returns from a character expression a string capitalized as appropriate for proper names.
RCHARINDEX(): Similar to the Transact-SQL function Charindex, with a Right search.
ARABTOROMAN(): Returns the character Roman numeral equivalent of a specified numeric expression (from 1 to 3999).
ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).

AT, PADL, PADR, CHRTRAN, PROPER: Similar to the Oracle functions PL/SQL INSTR, LPAD, RPAD, TRANSLATE, INITCAP.

Plus, there are CHM files in English, French, Spanish, German and Russian.

Plus, there are versions for MS SQL SERVER, SYBASE ASA, DB2, Oracle.

More than 8000 people have already downloaded my functions. I hope you will find them useful as well.

For more information about string UDFs MS SQL Server 2005 Transact-SQL SQLCLR (VB. Net, C#.Net, C++. Net) please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,29527

Please, download the file
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,29527

With the best regards.Igor! Long time no see! Its good to see that you've returned to re-enable the laugh track here at DBForums!

It will be interesting to see the reception of this incarnation of your library in a new (CLR) environment! Someday I may download this incarnation myself.

-PatP

Tuesday, March 6, 2012

[MSSQL + VS.NET] Connection - sleeping

Hello
I've prepared a small aplication in VS.NET and I use SqlConnection class.
Everything is ok, but when I'm trying to disconnect from server using
if (cnSQL->State != ConnectionState::Closed) cnSQL->Close()
there is still connection do server present. I have to close connection
because I'm trying to drop this database.
Have you ever heard about this kind of problem??

Trociu

--
Plain-text over all!!!
/**********/
write me : trociu@.autonom ict pwr wroc pl
search me : gg: 1382729"Trociu" <trociu@.autonom.ict.pwr.wroc.pl> wrote in message
news:slrncmhvuv.14n.trociu@.autonom.ict.pwr.wroc.pl ...
> Hello
> I've prepared a small aplication in VS.NET and I use SqlConnection class.
> Everything is ok, but when I'm trying to disconnect from server using
> if (cnSQL->State != ConnectionState::Closed) cnSQL->Close()
> there is still connection do server present. I have to close connection
> because I'm trying to drop this database.
> Have you ever heard about this kind of problem??
> Trociu
> --
> Plain-text over all!!!
> /**********/
> write me : trociu@.autonom ict pwr wroc pl
> search me : gg: 1382729

I have no idea, unless perhaps you're using connection pooling, and the pool
is still active? You might get a better response in a VB or .NET group.

From the server side, you can use ALTER DATABASE to disconnect all users
from a database - see Books Online:

ALTER DATABASE MyDB SET OFFLINE WITH ROLLBACK IMMEDIATE

Simon

Friday, February 24, 2012

[help] How do I have Asp.net kick off an SSIS Package on a different server?

Hello, I was wondering if someone can help me with an ASP.NET question. We have been having troubles with our web server, and I don't know where else to turn.

We are running an asp.net (vb.net) with IIS on ourWebServer.

We are running Sql Server 2005 / SSIS on ourDatabaseServer.

SQL Server and IIS are running on separate machines. This is by design.

We are trying to get our Asp.net to kick off an SSIS package, but we are unable to do this since the software is on separate servers.

(If both are installed on the web server, we can directly call the SSIS package. If both are installed on the Database Server, we can implement a web service on the Database Server, and call that web service from the Web Server.)

Thank you,


~Le

How are you trying to do that?

|||

>>How are you trying to do that?

Currently we are not doing it, which is why I am here.


On development, we are able to call the SSIS directly from Asp.net, as long as IIS and Integration Services is on the same machine.

In a different development environment, IIS is installed on the Machine01 and ISS + Integration Services is installed on Machine02. The Asp.net page runs off of Machine01 and calls a Web Service that is running on Machine02. That Web Service is able to activate the SSIS since Integration Services is on the same machine.

On our production server, we will not have either luxury. IIS is installed on the Web Server and Integration Services is installed on the Database Server.

So, how can we run it in our production environment?

~Le

|||

Sorry for the late reply, but I still dont understand that what will change in new development environment.

Currently you have SSIS on database server and asp.net(with IIS) on different machine and later its going to be the same. You can have the webservice running either on your asp.net machine or on Machine02, whichever you prefer.

Sunday, February 19, 2012

[F4] properties dialog does not follow convention of defaultvalue <> bold, changedvalue=bo

Just thought I'd point it out as something that needs fixing. This is inconsistent with every other MS product using the VS.net IDE framework.

I'd post it on Connect but then I'd wait 2 months to get "won't fix - this does not 'fit' with the current Katmai schedule" i.e. if I'm lucky (based on the new improved 3yr delivery of sql) it might get delivered in 2011. Wow.

Imagine if Xbox or PS3 designers told their customers, "sorry we know that up/down/left/right are in fact right/left/down/up, as you may expect on a game controller, but if you wait 3 years we might fix it"

I'm tired of your attitude regarding Connect. That is the means we have in place right now. Submit the Connect bug and move on. At least then it is flagged.|||
Adolf,

I would suggest to open a a report in connect and to place the link in this thread; that way others can add their vote if they want. I agree on something, requests at connect sometimes do not get the attention we would want, but you always have the opportunity of replying back.|||

Rafael Salas wrote:


Adolf,

I would suggest to open a a report in connect and to place the link in this thread; that way others can add their vote if they want. I agree on something, requests at connect sometimes do not get the attention we would want, but you always have the opportunity of replying back.

And at least there is an official record of the bug. That is the most important part.

[DBNETLIB][ConnectionOpen(Connect()).] SQL Server does not exist or access denied

ok im a CS student, installed visual studio .net, and im trying to connect to a ms sql database (Northwind), but I keep getting a error that "[DBNETLIB][ConnectionOpen(Connect()).] SQLServer does not exist or access denied" in visual studio whenever I try creating a new database connection. How do I know if SQL server is installed on my system? cuz in my systray I see SQL server service manager, is that the same thing as SQL server? or do I need to download the full version or something? also could it be that a certain port on my system is not open that SQL server requires to be open?

Thanks

Ron

The tray icon doesn't mean SQL is running, so use the tray icon to start SQL if it isn't. I do not know if SQL Express uses a tray icon, so i would assume you are using MSDE 2000. You might need to grant the user ASPNET access to the database.

SQL uses Port 1433. DTE services use ports 5000-5020, however I don't think you are using DTE.

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied - PLEASE

Hi have created an application in asp.net to connect to a sql database.
The reason why I am sooooo very confused is because the connection to the database works if i keep the project on my local machine and connect to the database on the server, but as soon as I upload the project to the server, I get the following error when I try to connect to the database:
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied
Can anyone tell me why this is happenning? - PLEASE - Any help will be appreciated
Thanks,
Danielle


you might want to check your connection string and make sure its pointing to the rigtht database server.

Thursday, February 16, 2012

[Ask]Getting files from pocket pc emulator to desktop pc

hi...!
I'm creating a small device application using visual studio.NET 2003. Is it possible to get a sql server ce database file (.sdf) that i created at the pocket pc emulator to my desktop pc ?
If that's possible, then can you tell me how to do that ?

thanx b4

Moving this thread to SQL Mobile forum where it has got better chances of being answered.

-Thanks,

Mohit

|||

Yes, you sure can copy this file (e.g. by using file explorer on emulator and network drive on PC). But you can't use it on desktop.

|||Can you tell me what should i do to copy the file, more specifically (step by step) ?
I don't have a plan to use it on desktop, I just want to copy the .sdf file from emulator to desktop, then to the real pocket pc

thanx
|||

Please see this (don't mind it mentions wireless network, work the same way on emulator):

http://pocketpccentral.net/help/browsewlan.htm

Monday, February 13, 2012

[.NET and SQL Server 2000] Explicit order Insert

My current project, which I am programming in .NET, requires me to insert a
variable number of rows, which make up a set, in a specific order. A
collection of sets that are inserted one after the other is a batch. Rows in
each set MUST be kept together, and sets in each batch MUST be kept together
.
What is the best way to implement this, both on the .NET side and also the
SQL Server side? Should I lock the table from inserts and updates (updating
won't be a problem, but inserting will be) before I start inserting rows? Ho
w
would I implement a system that would roll back all the inserts that have
occured in that batch if an error occurs?
Thank you very much,
Yohan MacDonaghLooking more into it, it looks like the best way is to use the DataSet and
DataAdapter objects in .NET.
Can anyone answer this, however: when a datasource is being updated via a
DataAdapter, is the table locked from inserts during the update?
"Yohan" wrote:

> My current project, which I am programming in .NET, requires me to insert
a
> variable number of rows, which make up a set, in a specific order. A
> collection of sets that are inserted one after the other is a batch. Rows
in
> each set MUST be kept together, and sets in each batch MUST be kept togeth
er.
> What is the best way to implement this, both on the .NET side and also the
> SQL Server side? Should I lock the table from inserts and updates (updatin
g
> won't be a problem, but inserting will be) before I start inserting rows?
How
> would I implement a system that would roll back all the inserts that have
> occured in that batch if an error occurs?
> Thank you very much,
> Yohan MacDonagh|||"Yohan" <Yohan@.discussions.microsoft.com> wrote in message
news:A0C46B5C-6B07-46F1-9203-D3B4EDDD341F@.microsoft.com...
> My current project, which I am programming in .NET, requires me to insert
> a
> variable number of rows, which make up a set, in a specific order. A
> collection of sets that are inserted one after the other is a batch. Rows
> in
> each set MUST be kept together, and sets in each batch MUST be kept
> together.
> What is the best way to implement this, both on the .NET side and also the
> SQL Server side? Should I lock the table from inserts and updates
> (updating
> won't be a problem, but inserting will be) before I start inserting rows?
> How
> would I implement a system that would roll back all the inserts that have
> occured in that batch if an error occurs?
A subset of rows must be defined in terms of shared column values. So give
each row a BatchID and a SetID.
David|||Unfortuantly, I cannot. I am limited by an existing (and very old) data
schema. There are no relationships. Each property of an object in .NET is a
new row in this schema (very weird, I know).
"David Browne" wrote:

> "Yohan" <Yohan@.discussions.microsoft.com> wrote in message
> news:A0C46B5C-6B07-46F1-9203-D3B4EDDD341F@.microsoft.com...
> A subset of rows must be defined in terms of shared column values. So giv
e
> each row a BatchID and a SetID.
> David
>
>

[.NET and SQL Server 2000] Explicit order Insert

My current project, which I am programming in .NET, requires me to insert a
variable number of rows, which make up a set, in a specific order. A
collection of sets that are inserted one after the other is a batch. Rows in
each set MUST be kept together, and sets in each batch MUST be kept together.
What is the best way to implement this, both on the .NET side and also the
SQL Server side? Should I lock the table from inserts and updates (updating
won't be a problem, but inserting will be) before I start inserting rows? How
would I implement a system that would roll back all the inserts that have
occured in that batch if an error occurs?
Thank you very much,
Yohan MacDonagh
Looking more into it, it looks like the best way is to use the DataSet and
DataAdapter objects in .NET.
Can anyone answer this, however: when a datasource is being updated via a
DataAdapter, is the table locked from inserts during the update?
"Yohan" wrote:

> My current project, which I am programming in .NET, requires me to insert a
> variable number of rows, which make up a set, in a specific order. A
> collection of sets that are inserted one after the other is a batch. Rows in
> each set MUST be kept together, and sets in each batch MUST be kept together.
> What is the best way to implement this, both on the .NET side and also the
> SQL Server side? Should I lock the table from inserts and updates (updating
> won't be a problem, but inserting will be) before I start inserting rows? How
> would I implement a system that would roll back all the inserts that have
> occured in that batch if an error occurs?
> Thank you very much,
> Yohan MacDonagh
|||"Yohan" <Yohan@.discussions.microsoft.com> wrote in message
news:A0C46B5C-6B07-46F1-9203-D3B4EDDD341F@.microsoft.com...
> My current project, which I am programming in .NET, requires me to insert
> a
> variable number of rows, which make up a set, in a specific order. A
> collection of sets that are inserted one after the other is a batch. Rows
> in
> each set MUST be kept together, and sets in each batch MUST be kept
> together.
> What is the best way to implement this, both on the .NET side and also the
> SQL Server side? Should I lock the table from inserts and updates
> (updating
> won't be a problem, but inserting will be) before I start inserting rows?
> How
> would I implement a system that would roll back all the inserts that have
> occured in that batch if an error occurs?
A subset of rows must be defined in terms of shared column values. So give
each row a BatchID and a SetID.
David
|||Unfortuantly, I cannot. I am limited by an existing (and very old) data
schema. There are no relationships. Each property of an object in .NET is a
new row in this schema (very weird, I know).
"David Browne" wrote:

> "Yohan" <Yohan@.discussions.microsoft.com> wrote in message
> news:A0C46B5C-6B07-46F1-9203-D3B4EDDD341F@.microsoft.com...
> A subset of rows must be defined in terms of shared column values. So give
> each row a BatchID and a SetID.
> David
>
>

[.NET and SQL Server 2000] Explicit order Insert

My current project, which I am programming in .NET, requires me to insert a
variable number of rows, which make up a set, in a specific order. A
collection of sets that are inserted one after the other is a batch. Rows in
each set MUST be kept together, and sets in each batch MUST be kept together.
What is the best way to implement this, both on the .NET side and also the
SQL Server side? Should I lock the table from inserts and updates (updating
won't be a problem, but inserting will be) before I start inserting rows? How
would I implement a system that would roll back all the inserts that have
occured in that batch if an error occurs?
Thank you very much,
Yohan MacDonaghLooking more into it, it looks like the best way is to use the DataSet and
DataAdapter objects in .NET.
Can anyone answer this, however: when a datasource is being updated via a
DataAdapter, is the table locked from inserts during the update?
"Yohan" wrote:
> My current project, which I am programming in .NET, requires me to insert a
> variable number of rows, which make up a set, in a specific order. A
> collection of sets that are inserted one after the other is a batch. Rows in
> each set MUST be kept together, and sets in each batch MUST be kept together.
> What is the best way to implement this, both on the .NET side and also the
> SQL Server side? Should I lock the table from inserts and updates (updating
> won't be a problem, but inserting will be) before I start inserting rows? How
> would I implement a system that would roll back all the inserts that have
> occured in that batch if an error occurs?
> Thank you very much,
> Yohan MacDonagh|||"Yohan" <Yohan@.discussions.microsoft.com> wrote in message
news:A0C46B5C-6B07-46F1-9203-D3B4EDDD341F@.microsoft.com...
> My current project, which I am programming in .NET, requires me to insert
> a
> variable number of rows, which make up a set, in a specific order. A
> collection of sets that are inserted one after the other is a batch. Rows
> in
> each set MUST be kept together, and sets in each batch MUST be kept
> together.
> What is the best way to implement this, both on the .NET side and also the
> SQL Server side? Should I lock the table from inserts and updates
> (updating
> won't be a problem, but inserting will be) before I start inserting rows?
> How
> would I implement a system that would roll back all the inserts that have
> occured in that batch if an error occurs?
A subset of rows must be defined in terms of shared column values. So give
each row a BatchID and a SetID.
David|||No such thing as an ordered INSERT. What you need to do is add a batch
number or othetr identifier to tell you what batches belong together.
--
David Portas
SQL Server MVP
--|||Unfortuantly, I cannot. I am limited by an existing (and very old) data
schema. There are no relationships. Each property of an object in .NET is a
new row in this schema (very weird, I know).
"David Browne" wrote:
> "Yohan" <Yohan@.discussions.microsoft.com> wrote in message
> news:A0C46B5C-6B07-46F1-9203-D3B4EDDD341F@.microsoft.com...
> > My current project, which I am programming in .NET, requires me to insert
> > a
> > variable number of rows, which make up a set, in a specific order. A
> > collection of sets that are inserted one after the other is a batch. Rows
> > in
> > each set MUST be kept together, and sets in each batch MUST be kept
> > together.
> >
> > What is the best way to implement this, both on the .NET side and also the
> > SQL Server side? Should I lock the table from inserts and updates
> > (updating
> > won't be a problem, but inserting will be) before I start inserting rows?
> > How
> > would I implement a system that would roll back all the inserts that have
> > occured in that batch if an error occurs?
> A subset of rows must be defined in terms of shared column values. So give
> each row a BatchID and a SetID.
> David
>
>|||In that case please explain what you mean by a batch being "kept
together". Are you referring to an IDENTITY column here? Please post
DDL and sample data so that we can understand the problem:
http://www.aspfaq.com/etiquette.asp?id=5006
--
David Portas
SQL Server MVP
--

Saturday, February 11, 2012

@@TRANCOUNT - always 0 or 1 ?..

I am trying to debug our production problem, and I'm stuck...

A C# .NET 1.1 method creates a SqlTransaction object on a SqlConnection. [This method is called from an ASP.NET 1.1 web application.]

The command invokes a stored procedure on SQL Server 2000 SP4 database.

The stored procedure itself is inside a transaction (that is, all batch code is between BEGIN TRANSACTION and COMMIT/ROLLBACK...).

DECLARE @.a_tran_count INT

SET @.a_tran_count = @.@.TRANCOUNT

DECLARE @.a_tran_name CHAR(13)

SET @.a_tran_name = CONVERT(CHAR(13), @.a_tran_count)

BEGIN TRANSACTION

DECLARE @.a_error INT

<Statements>

SET @.a_error = @.@.ERROR

IF 0 = @.a_error

<Statements>

SET @.a_error = @.@.ERROR

IF 0 = @.a_error

<Statements>

SET @.a_error = @.@.ERROR

IF @.@.TRANCOUNT > @.a_tran_count

BEGIN

IF 0 <> @.a_error

ROLLBACK TRANSACTION @.a_tran_name

COMMIT TRANSACTION

IF 0 = @.a_error

END

RETURN(@.a_error)

Apparently, there is an error in the last IF block (there should be ELSE just before COMMIT), and I don't like the error handling (it would be much more efficient to just rollback the transaction as soon as @.@.ERROR <> 0), but what I got stuck with is the following:

Is it possible that @.@.TRANCOUNT server variable will ever be other than 0 or 1?

I wrote some test page in C#, and it proved that SqlConnection indeed cannot support parallel transactions. But that's a .NET object, NOT a SQL Server's transaction...

I researched BOL and MSDN, but failed to find an answer to the question: if there can be only one transaction per one connection, then what's the point of using @.@.TRANCOUNT? So far, the only usage of it that I can imagine is for checking whether the current transaction has been started...

Also, using the @.a_tran_count (which is @.@.TRANCOUNT) to build the transaction name is kinda confusing as well... Is this name really needed in a procedure like this one?.. And what happens if there is another transaction running on this server which name is the same (such as "0")? Which transaction will be rolled back?

If the value of the @.@.TRANCOUNT can (at least, theoretically, - under certain rare circumstances) be greater than 1, it would mean I have found the cause of our current critical production issue and would be able to fix it relatively easily. So, any help would be greatly appreciated.

Thank you.

@.@.trancount is incremented by one for each "begin tran" and is decremented by one for each "commit":

if @.@.trancount > 0 rollback

begin tran

select @.@.trancount --1

begin tran

select @.@.trancount --2

commit

select @.@.trancount --1

commit

select @.@.trancount --0

It is set to zero when a "rollback" is issued:

if @.@.trancount > 0 rollback

begin tran

select @.@.trancount --1

begin tran

select @.@.trancount --2

rollback

select @.@.trancount --0

Because of the fact that a "rollback" sets the transaction count to zero, SQL Server is not usually considered to fully support "nested transactions".

Ron

|||as explained...@.@.trancount count does increase with each transaction added...rollback its it to zero just to add that... commit does @.@.trancount - 1...

Thursday, February 9, 2012

@@IDENTITY question

Hi, friends. I got a question for @.@.IDENTITY when I was working on a C#.net project.

I use "SELECT @.@.IDENTITY, @.@.ERROR" in the stored procedure to retrieve the ID column of the row just inserted, and in my C# code, I try to access it with rdr.GetInt64(0) since ID column is bigint. However, there is a error. The type is not match. I must instead use rdr.GetDecimal(0) to access @.@.IDENTITY which is a bigint.

I got confused, anybody has any idea?

Thanks.

xufff::I got confused, anybody has any idea?

Sure. Get used to reading the documentation.

@.@.IDENTITY is a (documented, btw) variable that is defined by SQL Server. It is not created based on your data type in the ID column, it is predefined.

The documentation says that the data type of the @.@.IDENTITY variable is - numeric, which translates to decimal in the CLR.

So, according to the documentation (which I checked not to post garbage - took me 10 seconds) this is simply the expected behavior.

I would think that the reason for this is that it IS legal to have a decimal based ID field. Unusual, but legal. And they decided to use numeric for the variable type, simply because this is about the "largest" data type they can use, handling everything allowed for identity fields.

Now, all you have to do is convert this decimal to a bigint - which should not give you any problems.