|
I have a document storage system written in C# that has been running fine for over a year on a SQL 2000 database. I have a table that holds three BLOB field which contain files. The problem I'm having is, that this morning the files can no longer be retrieved from the table's BLOB field(s). When I query a record in the Query Analyzer the BLOB I'm attempting to get shows a value of 0x where the other field show values of 0x123423dj3ed24aq2 etc......anyone see this before ? Any ideas why SQL is not longer storing this BLOB field correctly ?
|
|
|
|
|
My application has one web form where admin can add as many users as desired and at the end when he press SaveChanges I want to add all of them to database, There should be some way to pass arrays to stored procedure..I am looking for it or something similar to this....
Any Ideas!!!
Thanks in advance...
MaulikCE
|
|
|
|
|
No, you can't pass an array. What you should do is open your connection and loop through array of users. Set the new parameter value and execute. Why would you need to pass an array?
"People who never make mistakes, never do anything."
My blog
http://toddsnotsoamazinglife.blogspot.com/
|
|
|
|
|
|
|
Another idea is :
To call the Update method on a SQLDataAdapter, passiing it a modified dataset containing new, changed and or deleted rows.
------------------------------------
To study, study and only to study
|
|
|
|
|
Suppose i connect to db (SQL Server) from the client (.NET) and call to some store procedure, in this sp i start transaction (BEGIN TRANSACTION) and before COMMIT or RALLBACK an error happen that imidietly stop the execution of stored procedure, In the client i cacth this error but what about an open transaction ???
HOW to rollback in the client???
------------------------------------
To study, study and only to study
|
|
|
|
|
I am not an expert in SQL by any means, and so I don't know if it is possible to do what you want. But if you could start you transaction on the client side, then you could undo everything. See SqlTransaction class.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Short answer: try SET XACT_ABORT ON...
"If a run-time statement error (such as a constraint violation) occurs in a batch, the default behavior in SQL Server is to roll back only the statement that generated the error. You can change this behavior using the SET XACT_ABORT statement. After SET XACT_ABORT ON is executed, any run-time statement error causes an automatic rollback of the current transaction. Compile errors, such as syntax errors, are not affected by SET XACT_ABORT.<br />
<br />
It is the responsibility of the programmer to code the application to specify the correct action (COMMIT or ROLLBACK) if a run-time or compile error occurs."
-- SQL Server Books Online
A better answer would be to include error handling. There's a very good article
here[^] that describes one strategy for getting more predictable results from stored procedures through error handling.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thank u in andvance.
------------------------------------
To study, study and only to study
|
|
|
|
|
Hello,
I want to get all of the rows of a table in my database which are suit some criteria in a stored procedure.
but ı dont know getting and returning table (multiple data) from a stored procedure.
How can ı success this..
|
|
|
|
|
CREATE PROCEDURE procName
@criteria1 int,
@criteria2 char ,
........
......
SELECT bla, bla bla... FROM tableName
WHERE bla = @criteria1 And .....
or using og JOIN.
something like that.
is it help?
------------------------------------
To study, study and only to study
|
|
|
|
|
|
Is Insert, Delete, Update already have transaction inside
if yes how it help us and for what it ??
To study, study and only to study
|
|
|
|
|
_J_ wrote:
Is Insert, Delete, Update already had transaction inside
I'm not entirely sure what you are asking, however I am guessing you are asking: Are INSERT, DELETE and UPDATE statements wrapped in a transaction?
Yes, and the SELECT statement too unless you wrap a sequence of these statements in a transaction. SQL Server will always wrap indiivdual statements in a transaction so that the statement can complete successfully and does not interfer with other queries or so other queries do not interfere with it.
Does this help?
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
OK, thanks. So if i do deletion and 100% shure that more than one row will deleted should use a transaction as i now understood No.
So i don't need to wrap it with my tranascation like :
Begin TRAN
DELETE .....
COMMIT
To study, study and only to study
|
|
|
|
|
I'm not sure that you understood me.
If you are doing one delete statement only then you don't need to explicitly wrap it in a transaction because SQL Server will do that for you. (NOTE: Other database products may vary)
So DELETE MyTable WHERE SomeColumn='SomeValue' does not have to be wrapped in a transaction. It can delete 0, 1 or many rows.
However, if you need to delete from, say, two separate tables at the same time you might want to use a transaction, so
BEGIN TRANSACTION
DELETE MyTable WHERE SomeColumn='SomeValue'
DELETE MyOtherTable WHERE SomeOtherColumn='SomeOtherValue'
COMMIT TRANSACTION
Obviously, after each delete you may want to check for errors so that you can roll back a transaction if it fails.
Does this help?
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Thank u, u r the best. Now everything clear me, Thanks in advance
I have another question to about transaction.
Transacttion in stoe proc , in the begining i save @@TRANCOUNT to local variable (@tranCount) after this i start transaction (BEGIN TRANSACTION), i do my work ... .. maybe call to other store procs, .. .. and now before COMMIT or ROLLBACK i must to check my local variable (@tranCount) with @@TRANCOUNT ??
------------------------------------
To study, study and only to study
|
|
|
|
|
There are other potential transaction configurations, depending upon the database platform and the method of access.
SQL Server runs, by default, in AutoCommit mode although it can be disabled, requiring explicit COMMIT or ROLLBACK calls.
Oracle does not run in AutoCommit mode by default (in fact I have never determined if it can; I doubt it).
Of course, neither of the above comments really matter if the developer is using a managed data provider, all of which (along with the underlying ODBC and OleDB layers) implement some form of AutoCommit heuristics as far as I know, forcing the behavior to act as you describe.
I'm mainly making the distinction between exec'ing SQL at the command line versus through a managed provider, on different DB servers.
Have a good weekend.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Question :
i have this table :
T
F X
_________________
F1 X1
F1 X2
F2 X6
F3 X3
. .
. .
. .
. .
Fn Xm
when i want Fs that their X is 'Xi OR Xj OR Xk' i will write
SELECT F FROM TABLE WHERE X IN( Xi , Xj , Xk )
when i want Fs that their X is 'Xi AND Xj AND Xk ' what should i write ?
|
|
|
|
|
Where X = Xi AND
X = Xj AND
X = Xk
To study, study and only to study
|
|
|
|
|
This will actually return nothing, since a single column cannot simultaneously be equal to three different values.
Try this:
Select F, count(distinct x)
from T
where X in (Xi, Xj, Xk)
group by F
having count(distinct x) = 3
Since we are only counting distinct values, and there are three distinct possiblities, a count of 3 means that all are present.
Tony Lewis
XAKTsoft, Inc.
|
|
|
|
|
Thanks
i have use your statement in my article but i got an error with below statement:
Select distinct ID,Name from [View]
where ID not in ( select ID from [View] where TypeID not in(1,3) )
group by ID having count(distinct typeID) = 2
ADO Error :Column [View].Name is invalid in the select list because it is not contained
in either an aggregate function or GROUP BY clause.
|
|
|
|
|
It means just what it says. Any column in the summary query (with a group by clause and aggregate columns like sum, count, etc.) that isn't summarized needs to be included in the group by clause. You need to add [Name] to your group by. I always put the aggregate columns at the end, copy the rest of the selected fields and paste them to the group by. Remember that the group by can't contain field aliases.
Tony Lewis
XAKTsoft, Inc.
|
|
|
|
|
This should work, although I don't know if it's the best way to do it:
SELECT <br />
F<br />
FROM<br />
T T0<br />
WHERE<br />
EXISTS (SELECT 1 FROM T T1 WHERE T1.F = T0.F AND X = Xi)<br />
AND<br />
EXISTS (SELECT 1 FROM T T2 WHERE T2.F = T0.F AND X = Xj)<br />
AND<br />
EXISTS (SELECT 1 FROM T T3 WHERE T3.F = T0.F AND X = Xk)
Of course, all the aliases are arbitrary, just make it easier for me to read.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|