|
Dear Code Project General Database Forum Readers,
I would like to bring your attention to an update and extension of the Walkthrough: Creating an N-Tier Data Application[^] article on the MSDN Library. The article details how to add Save Data and Refresh features to the user interface of the walkthrough's presentation layer. It also illustrates a basic filter and how to requery a TableAdapter object from code.
I invite you to read the article if you are interested in learning more abou N-Tier Data Access.
http://www.codeproject.com/KB/database/filter_update_n-tier.aspx[^]
Have a pleasant day.
V/R
Brian C. Hart, Ph.D.
|
|
|
|
|
i want to apply trigger on a particular table, so that same operation would occur in another table on different server. but whenever i try to perform this step , i received an error that distributed transaction not allowed.
Kindly help me out.
Aman
|
|
|
|
|
|
i am trying to runn this
BEGIN DISTRIBUTED TRANSACTION;
-- Delete candidate from local instance.
Insert into UserTest values(1211,'AMan',1,Getdate());
-- Delete candidate from remote instance.
Insert into [Replicabackup\replicadb].test.dbo.Userlist(UserID,Name,Status,CreatedDate,TriggeredDate,EventType)
values(1211,'AMan',1,Getdate(),Getdate(),'Inserted');
COMMIT TRANSACTION;
GO
but i got this error
Server: Msg 7391, Level 16, State 1, Line 8
The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' ITransactionJoin::JoinTransaction returned 0x8004d00a].
Kindly Help.
|
|
|
|
|
Check that the MSDTC service is running on the server where you start the transaction.
Also it's possible that your linked server connection doesn't support distributed transactions. You could check that remote proc trans is 1 using sp_configure .
|
|
|
|
|
my source server has sql 2000 and my destination server has sql 2005..
sql 2000 MSDTC services are already running... and i have also checked all the options in sql 2005 surface configuration manager..
i ran sp_configure command on my both servers. the values are :- 1 ..
now tell me wht shd i do...
|
|
|
|
|
Aman786Singh wrote: i ran sp_configure command on my both servers. the values are - 1
-1 Possible values are only 0 and 1. You could also check this using Management Studio and the server properties dialog. I don't remember what the actual text was in connection definitions, but there should be a few check boxes you can set on like: are remote connections allowed and are distributed transactions required.
Another thing you could try is that before you start the transaction in your code you can call:
SET REMOTE_PROC_TRANSACTIONS ON
Also check this link: http://support.microsoft.com/kb/839279[^].
Then there's a small utility dtcping.exe, which you can use to determine if firewall is causing a problem. Downloadable here:http://www.microsoft.com/downloads/details.aspx?FamilyID=5e325025-4dcd-4658-a549-1d549ac17644&DisplayLang=en[^]
|
|
|
|
|
i mean to say value is 1 not -1... ok i will try your steps and let u know wht happen.. thanks in advance...
|
|
|
|
|
No problem. I found that there are severa problems for SQL Server 2000 on Windows 2003 server concerning DTC. Lots of hotfixes available so you might want to check those also.
|
|
|
|
|
The following code is used in the where clause in a stored procedure and it will not compile.
CASE WHEN @ciSubjectId <> '' THEN tJ.cdSubjectCode LIKE '%' + @ciSubjectId + '%' ELSE tJ.cdSubjectCode LIKE tJ.cdSubjectCode END
How can I get this to compile?
|
|
|
|
|
You cannot use CASE to modify the logic in where clause. Instead you must redefine the logic. If I understood you correctly, you use @ciSubjectId if it's not empty , otherwise you use an exact match which is always true (unless the value inside cdSubjectCode is NULL. If that was correct, your statement could be something like:
... tJ.cdSubjectCode LIKE (CASE @ciSubjectId
WHEN '' THEN tJ.cdSubjectCode
ELSE '%' + @ciSubjectId + '%'
END)...
|
|
|
|
|
The change you suggested compiles but always returns 0 rows.
|
|
|
|
|
Could it be because of other conditions or the value in the variable. I made a simple test and it seems to work fine. You can try this on your database and change the value of @ciSubjectId to whatever you like:
declare @ciSubjectId varchar(50);
SET @ciSubjectId = 'table';
SELECT *
FROM sysobjects
WHERE
--tJ.cdSubjectCode
name LIKE (CASE @ciSubjectId
WHEN '' THEN name
ELSE '%' + @ciSubjectId + '%'
END)
|
|
|
|
|
The following code is used in the where clause in a stored procedure and will error when @ciDept = '4,25'. It works when @cilocn = '4'
tLD.idClientDeptNumb IN (CASE WHEN @ciDept <> '' THEN CONVERT(INT, @ciDept) ELSE tLD.idClientDeptNumb END
The error thrown is:
Syntax error converting the varchar value '4,25' to a column of data type int.
How can this error be resolved?
|
|
|
|
|
dptalt wrote: Syntax error converting the varchar value '4,25' to a column of data type int
decimal separator in SQL is dot. If you're unable to modify it on the calling side, you can use replace function to modify it in the stored procedure or in the statement.
Also integer cannot handle decimals so you should use for example real as datatype:
tLD.idClientDeptNumb IN (
CASE
WHEN @ciDept <> ''
THEN CONVERT(REAL, REPLACE(@ciDept, ',', '.'))
ELSE tLD.idClientDeptNumb
END...
But if you can, prefer using numeric variables if they contain numeric data.
|
|
|
|
|
Replacing ',' to '.' always returns 0 rows.
I thought the IN list command requires the elements in the list to be separated by commas?
If I do not replace the commas with decimals I get the following error:
Error converting data type varchar to real.
|
|
|
|
|
As in the other post from you, could it be because of other conditions. If it's not working, could you post the whole query.
|
|
|
|
|
Hi experts.
I have a basic question .
I'm going to create a local database for may WPF App, but I don't know which one is better, sdf database or mdf database.
I've searched , but couldn't find anything special.
Could you explain the differences between them ?
Thanks in advance.
|
|
|
|
|
mdf will require a Sql Server installation (can be express) while sdf will run without any database.
Mdf should have better performance since it runs on an actual database, but sdf will be much easier to deploy
|
|
|
|
|
|
Both are a real database file. .sdf file are called embedded database (the database server is just a class library that you access) so your application will become the database "server".
|
|
|
|
|
First: i'm sorry for my bad english
I've a problem,
in my webaplication, i use sqlite to manage some data for links
in a simple favourite links page. To get all links i use:
$connectionhandle = sqlite_open('mystart2', 0666, $sqliteerror);
$result = sqlite_query($connectionhandle, $query, SQLITE_ASSOC);
$result = sqlite_fetch_array($result);
print_r($result);
ok, the functions for connecting and doing the query are capsuled
in classes but i think that doesn't matter
This query returns just the first row from this table,
so just one row, but i'm sure that there exists at least 3 rows.
That means that the query should return 3 rows, not just one.
What's the problem?
modified on Friday, January 16, 2009 4:43 PM
|
|
|
|
|
Hi,
it may be wise to show us some code, the SQL line seems fine.
modified on Friday, January 16, 2009 8:57 AM
|
|
|
|
|
Hi all,
I have table with data in my database as follows
table name :sample (col 'ps' is primary key)
village ps val
1 1 56
1 2 67
1 3 65
1 4 70
2 5 74
2 6 64
2 7 32
3 8 46
3 9 56
4 10 64
My requirement is i have to get the Count of 'village' whose val > 60 and val < 60
for that i tried in the following way..(for finding avg 'val' of villages)
select sum(val)/count(ps) assessment from sample group by village
output:
assessment
66
56
59
54
But i need the count of above assessment values > 60 and < 60
i.e count of assessment > 60 , < 60
For that i tried in following way(i know i wrote wrong...but it gives you the idea what i am trying for)
select count(*) sample where (select sum(val)/count(ps) assessment from sample group by village) > 60
Please suggest me how to do that...
thanks in advance.
|
|
|
|
|
you need to use HAVING...
something like:
select sum(val)/count(ps) assessment from sample group by village HAVING sum(val)/count(ps) > 60
let me know if it helps
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|