|
Ensure that the TCP/IP port SQL Server is using is exposed through the firewall.
If you are using SQL Server 2000 you can find this out with the Enterprise Manager:
Right click the server icon for the server you wish to expose. Click Network Configuration. Ensure that TCP/IP is in the Enabled list (if not, seek advice from your Network Admin). Click TCP/IP in the Enabled list and click the "Properties" button below it. It will tell you the default port. You need to open that port on the firewall to see the SQL Server.
|
|
|
|
|
Keberos does not travel well across VPN links. Try using SQL user connections rather than trusted.
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|
|
Hello.. I wonder if someone here could help me.
I have 2 MSSQL Server 2000 databases installed on 2 different machines. These are named Master & Servant. The master db is a Windows 2003 machine. The servant DB is Windows XP machine.
- I have successfully setup a linked server on the master that references the Servant DB.
- I then written a stored-proc on the Servant which adds a record to a table.
- i have successfully called this stored-proc from master db which adds a new row to the table.
When, however i try to call this stored-proc from a triger on the master db i recieve the following error.
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].
My trigger currently looks like this:
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'trig_testCopyDataAcrossDb' AND type = 'TR')<br />
DROP TRIGGER trig_testCopyDataAcrossDb<br />
GO<br />
CREATE trigger trig_testCopyDataAcrossDb on testbed FOR update, insert AS<br />
<br />
BEGIN<br />
SET XACT_ABORT ON -- this is required for distributed transactions.<br />
SET IMPLICIT_TRANSACTIONS OFF <br />
BEGIN DISTRIBUTED TRANSACTION distTrans<br />
<br />
--insert into servant.testbed.dbo.mytable ( DateTimeRaised ) VALUES ( getdate() )<br />
exec servant.testbed..sp_AddRecord<br />
<br />
COMMIT TRANSACTION<br />
END
What i must stress here and what i find wierd is that am able to call the stored-proc from Query Analyzer with success. I am only recieving this error when trying to call this stored-proc from my trigger.
-- modified at 12:17 Monday 9th October, 2006
|
|
|
|
|
Okay guys this one definatly tripped me up but ive managed to find a way to sort it. Firstly this table syncronisation is only a tempory job which i want for a couple of weeks so i didnt want to go through the whole replication bag. That is just to heavy-duty for what i need, and something that want be around in a month or so.
So, after reading a post over at MSDN forums i found that the reason why the call to the stored-proc works inside Query Analyzer. Query Analyzer only requires the oledb to support ITransactionLocal. - But triggers require ITransactionJoin.
I looked into distributed transactions but but couldnt come up with any work-arounds. It looks like there is a problem with our security settings and distributed transactions across the two servers.
In the end i stumbled upon this hack and added a "COMMIT TRANSACTION" as the first line of the trigger and this worked. - I guess this is commiting the distributed transaction first. Then i added the call to my stored-proc which now works.
the trigger now looks like this:
<br />
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'trig_testCopyDataAcrossDb' AND type = 'TR')<br />
DROP TRIGGER trig_testCopyDataAcrossDb<br />
GO<br />
CREATE trigger trig_testCopyDataAcrossDb on testbed FOR update, insert AS<br />
<br />
BEGIN<br />
COMMIT TRANSACTION<br />
EXEC servant.testbed..sp_AddRecord<br />
END
|
|
|
|
|
Hello,
I have a problem trying to connect a remote sql server. The error:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
DEVSQL computer name
RealitySolutions instance name
Using a windows application on a LAN.
my connection string is:
connectionString="server=DEVSQL\REALITYSOLUTIONS; database=ServiceMaster; Integrated Security=True
This is what I have done:
Enabled TCP/IP and named pipes and share memory protocals on my instance in configuratoin management.
surface area configuration I have enabled enabled remote connection using TCP and Named pipes.
I still get the above error message.
Any help will be most grateful, and I think i have tried everything.
Thanks
Steve
|
|
|
|
|
if connect to server on otder machine,use machine-IP\instance-id,otherwise use "(local)".
btw,maybe need config the client-network information with SQL Server Client Network Utility,the server-ip and port,etc.
|
|
|
|
|
Hello,
thanks for your reply.
But i think the ip address would be used for connecting to a remote server on the internet. Local would be the local server on my machine not a remote one.
How do i config client-network information with sql server? Not sure about this.
Thanks in advance,
Steve
|
|
|
|
|
Data Source="SQLServerIP\InstanceName";Initial Catalog="DataBase";Persist Security Info=True;User ID="UserID";Password="Password"
Obviously the " are just to separate the required values and what you will modifiy.
|
|
|
|
|
Hello private_void,
Thanks for your reply.
I have noticed you are using that connection string with a sql security. Currently I have my sql server setup for Windows authenication. That is why I never had the pwd or username.
Just wondering, can you connect remotely with windows authentication? If so, have I missed something about windows user account? security login?
Please if you have any idea about windows authentication.
thanks very much,
Steve
|
|
|
|
|
try to config an alias for "DEVSQL" with sql server client network utility.
ps: DEVSQL <=> IP on Lan
i have only use SSPI in same machine,not lan or internet yet.:p
|
|
|
|
|
Thanks for your reply yahao,
But I am sure what you mean by:
yahao wrote: config an alias for "DEVSQL" with sql server client network utility
How will this help solve the current problem?
I have connected to sql server many times. This the first time remotely.
The server I am using is 2005 developer edition.
Many thanks again,
Steve
|
|
|
|
|
or try to directly connect remote server use IP rather than use machine name.
this is the fun of resolve problem.
|
|
|
|
|
Well I think you should use the IP address. This should be a static IP. If it is not that could be why you are having problems. When you enable the connections via Pipes you should reboot the Server. I don't see anything wrong with your connection string and yes SQL 2005 does allow Windows Authentication, but you still have to set up a Login under Security\Logins. The user name should be Domain\WindowsUserAccount. If you have any questions regarding connections strings there is a great website; http://www.connectionstrings.com.
Hope this helps.
|
|
|
|
|
I have a question that I was hoping someone could help me with. I am using VB.net 2005 express edition with SQL Server 2005 Express edition.
I have a database that has a table in it called Folder. It consists of two fields. One is called folderId and folderName.
I want to add a new row to this folder by calling a second form from my main form. For example, say I open up a second form from my main form. This second form consists of a text box and an button called OK. The user will enter the new folder name into the text box. How do I make it so the name the user enters into the text box is added to the folder table.
|
|
|
|
|
Please stick to your original thread[^].
Posting the same question in different forums is rude. Be patient and someone will give you an answer to your question.
|
|
|
|
|
He's a very naughty boy
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|
|
|
I'm designing a database (at which I do not have much knowledge) and I have a question. I want to have a table that has properties, such as title, author, length, etc for books and one of the properties I want is genre (fiction, non-fiction, thriller, etc). Here's my problem, each book could be have than one category so how would I set that up? I want to have the Books table with a Genre field which would be a FK to the Genre table. What I'm not sure about is storing the values because of normalization ie. if I just stored the GenreID's as a comma seperated list in the Genre field wouldn't that break normalization not to mention make it harder to parse...I'm just a little confused with how to design this and any help would be appreciated.
Thanks.
- Aaron
|
|
|
|
|
Don't store the data as a a comma separted list. You need a Book_Genre table that stores the book_id and the genre_id, is covered by a unique index and links to the Book and genre tables on the key fields.
|
|
|
|
|
This is a many-to-many join that you are describing:
One book can have many genres. One genre can contain many books.
What you need is an intermediate table. These are necessary to model many-to-many joins. The intermediate tables contains a compound primary key made up of the primary keys of the tables that are being joined together. In this case a Book table and a Genre table.
The intermediate table BookGenre will look like this:
BookId int not null PK
GenreId int not null PK To join a book to a genre you create a new row in the BookGenre table with the corresponding primary keys. The act of making the compound primary key in the intermediate table ensures that you don't have duplicate joins. e.g. Terry Prattchet's Thump listed as Fantasy twice, or vice versa.
Does this help?
|
|
|
|
|
This is exactly what I'm looking for, thanks very much for the help. It makes a lot of sense, but it's not something I would have thought of.
Thanks again!
- Aaron
|
|
|
|
|
hi
can anyone plz help me debug this procedure and tel me if there is any other software that helps us write and debug stored procs in a much convinient way
I'm using SQL server 2000 by the way.
and this is the error...
--------------------------------------------------
Error 156: Incorrect syntax near the keyword 'SET'.
---------------------------------------------------
CREATE PROCEDURE dbo.BranchBillDetailInsertCombo
(
@BillID numeric(18),
@Quantity int,
@Serial varchar(30),
@prodLineID numeric(18),
@ManID numeric(18),
@ModelID numeric(18),
@PresentAT numeric(18),
@Error_code INT OUTPUT
)
AS
DECLARE @counter int
DECLARE @availableQty int
DECLARE @PurchID numeric(18)
DECLARE purch_cursor CURSOR FOR
SELECT purchid FROM vu_unsoldproducts
WHERE prodLineID = @prodLineID
AND Manid = @Manid
AND ModelID = @ModelID
AND Upper(Serial) = Upper(Serial)
AND presentAT = @presentAT
Select @avialbleQty = (select count(*) AvailableQty FROM vu_unsoldproducts
Group by serial, prodlineid, manid, modelid HAVING prodlineid = @prodLineID AND manid = @manid AND modelid = @modelID AND UPPER(serial) = UPPER(@Serial)
SET @Error_code = 0 -- means there is no error in executing the stored procedure
IF @Quantity >@availableQty
BEGIN
SET @ERROR_CODE = -1
--return -- dubious statement... I dont know the syntax for that.
END
ELSE
BEGIN
OPEN purch_cursor
FETCH NEXT FROM purch_cursor
INTO @PurchID
Insert INTO branchBillDetail(BillID, purchID)
Values (@BillID, @purchID)
SET @counter = 1
WHILE (@@FETCH_STATUS = 0) OR (@Counter < @Quantity)
BEGIN
SET @counter = @counter + 1
-- @counter++
FETCH NEXT FROM purch_cursor
INTO @PurchID
Insert InTo branchBillDetail(BillID, purchID)
Values (@BillID, @purchID)
END
CLOSE purch_cursor
DEALLOCATE purch_Cursor
END
Rocky
|
|
|
|
|
there has two mistake in your code:
1.missing a right bracket at the end of "Select @avialbleQty = (..."
2.the var @availableQty is not equal definition
The code after DEBUG:
CREATE PROCEDURE dbo.BranchBillDetailInsertCombo
(
@BillID numeric(18),
@Quantity int,
@Serial varchar(30),
@prodLineID numeric(18),
@ManID numeric(18),
@ModelID numeric(18),
@PresentAT numeric(18),
@Error_code INT OUTPUT
)
AS
DECLARE @counter int
DECLARE @availableQty int
DECLARE @PurchID numeric(18)
DECLARE purch_cursor CURSOR FOR
SELECT purchid FROM vu_unsoldproducts
WHERE prodLineID = @prodLineID
AND Manid = @Manid
AND ModelID = @ModelID
AND Upper(Serial) = Upper(Serial)
AND presentAT = @presentAT
Select @availableQty = (select count(*) AvailableQty FROM vu_unsoldproducts
Group by serial, prodlineid, manid, modelid
HAVING
prodlineid = @prodLineID
AND
manid = @manid
AND
modelid = @modelID
AND
UPPER(serial) = UPPER(@Serial))
SET @Error_code = 0 -- means there is no error in executing the stored procedure
IF @Quantity >@availableQty
BEGIN
SET @ERROR_CODE = -1
--return -- dubious statement... I dont know the syntax for that.
END
ELSE
BEGIN
OPEN purch_cursor
FETCH NEXT FROM purch_cursor
INTO @PurchID
Insert INTO branchBillDetail(BillID, purchID)
Values (@BillID, @purchID)
SET @counter = 1
WHILE (@@FETCH_STATUS = 0) OR (@Counter < @Quantity)
BEGIN
SET @counter = @counter + 1
-- @counter++
FETCH NEXT FROM purch_cursor
INTO @PurchID
Insert InTo branchBillDetail(BillID, purchID)
Values (@BillID, @purchID)
END
CLOSE purch_cursor
DEALLOCATE purch_Cursor
END
|
|
|
|
|
Hey thanks a lot man I really appreciate it, well its just that at the moment I'm not feeling at home with this syntax u know
but is there any other tool in which we can easily see our mistakes like for example .net environment helps alot in that regard.
thanks again
Rocky
|
|
|
|
|
hi!
I wrote sql server stored procedure since 2002,as a matter of experience,the best way to reduce bugs and errors is keep good habit for coding.
for example,code with EditPlus text-editor rather than sql server query analyzer,and use the syntax file & auto-completion for *.sql file type.
of course,one important factor is has clear structure of application,and then,produce high-quality code.
there is some code of mine:
/*
'##############################################################################
'## Copyright (C) 1998-2006 Yahao SoftWorks
'##
'## PROJ: FFS
'## SUBJ: get common present data
'##
'## Code by Yahao
'##############################################################################
'## C/U-Date: 2006-10-09
*/
-- Remove the existing Stored Procedure --
if (exists (select * from sysobjects where name = 'usp_m_getcPresentDetailData' and type = 'P'))
drop proc usp_m_getcPresentDetailData
go
CREATE PROCEDURE usp_m_getcPresentDetailData
(
---- In: op id ----
@inCmdID smallint,
---- In: obj id ----
@inOpItemID int,
---- In: obj name ----
@inOpItemName varchar(60),
---- Out: record amount ----
@otcPresentAmount int OUTPUT,
---- Ret ----
@ReturnValue int OUTPUT
)
WITH ENCRYPTION
AS
SET NOCOUNT ON
DECLARE @intRetValue As int,@intErrCode As int
DECLARE @intcPresentAmount As int
IF @@NESTLEVEL = 1
BEGIN
SET @ReturnValue = 99
RAISERROR ('illegal call',16, 1)
RETURN
END
---- var init ----
SET @intErrCode = 0
SET @intcPresentAmount = 0
---- RS1: present data ----
SELECT
PresentName,
StockAmount,
AvgStockPrice,
OptionSet,
CatID,
StockStatusTID,
Remark,
CreateOn,
Status
FROM onenb_shop.dbo.CommonPresentData
WHERE PresentID = @inOpItemID
---- return data ----
SET @otcPresentAmount = @intcPresentAmount
SET @ReturnValue = 0
SET NOCOUNT OFF
|
|
|
|