Showing posts with label via. Show all posts
Showing posts with label via. Show all posts

Thursday, March 29, 2012

Direct connection Windows CE 4.2 + SQL Server 2005

Hello,

I have a problem with SqlClient (WindowsCE 4.2 & .NET CF2.0 SP2). PDA is connects on PC via USB-cradle and ActiveSync 4.0. PC is in the LAN and SQL Server 2005 is in the LAN too. I can't connect to SQL Server 2005 (after connection.Open() I get exception "PlatformNotSupported"). When I use SQL Server 2000, it's O.K.

Can I connect on the SQL Server 2005 from Windows CE 4.2?

Thanks.

See this.

Thursday, March 22, 2012

dijkstras algoritm problem

I want to make it possible that I can see the path from one user to another and via whom the route went:

I want to pass the startnode and the endnode and then retreive the route between them.
In case I go from 5 to 15 (see table below), I want to have the following returned:
5-6-15
5-7-15

In case I go from 5 to 18 I want to have returned:

5-6-15-9-18
5-7-15-9-18

always up to a maximum distance of 6 steps.

I have the following table definition
tblFriends
OwnerCode int
FriendCode int

this table contains content like:

56511576561261561171575915918115116126136156157159189


As you can see, I store each relationship twice.

I have created the following SP to retreive the info, but dont know how I can get from these results to the results I desire as described above...
STORED PROCEDURE

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[myspShortestPath]
--shortest path based on algorythm of Dijkstra
@.ViewingUserCode int,
@.ViewedUserCode int,
@.MaxDistance int=100,
@.MinDistance int
AS
BEGIN

-- Automatically rollback the transaction if something goes wrong.
SET XACT_ABORT ON
BEGIN TRAN

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Create a temporary table for storing the estimates as the algorithm runs
CREATE TABLE #UserList
(
UserCode Int NOT NULL, -- The City Id
UserName nvarchar(50),
Estimate Int NOT NULL, -- What is the distance to this city, so far?
Predecessor nvarchar(max), -- The city we came from to get to this city with this distance.
PredecessorCodes nvarchar(max),
Done bit NOT NULL -- Are we done with this city yet (is the estimate the final distance)?
)

-- Fill the temporary table with initial data
INSERT INTO #UserList (UserCode, UserName, Estimate, Predecessor,PredecessorCodes, Done)
SELECT UserCode, UserName, 2147483647, '', '', 0 FROM tblUserData

-- Set the estimate for the city we start in to be 0.
UPDATE #UserList SET Estimate = 0 WHERE UserCode = @.ViewingUserCode
IF @.@.rowcount <> 1
BEGIN
RAISERROR ('Couldn''t set start user', 11, 1)
ROLLBACK TRAN
RETURN
END

DECLARE @.FromUser Int, @.CurrentEstimate Int,@.FromUserName nvarchar(50)

-- Run the algorithm until we decide that we are finished
WHILE 1=1
BEGIN
-- Reset the variable, so we can detect getting no records in the next step.
SELECT @.FromUser = NULL

-- Select the UserCode and current estimate for a city not done, with the lowest estimate.
SELECT TOP 1 @.FromUser = UserCode, @.FromUserName = UserName, @.CurrentEstimate = Estimate
FROM #UserList WHERE Done = 0 AND Estimate < 2147483647

-- Stop if we have no more unvisited, reachable cities.
IF @.FromUser IS NULL BREAK

-- We are now done with this city.
UPDATE #UserList SET Done = 1 WHERE UserCode = @.FromUser

-- Update the estimates to all neighbour cities of this one (all the cities
-- there are roads to from this city). Only update the estimate if the new
-- proposal (to go via the current city) is better (lower).
UPDATE #UserList SET #UserList.Estimate = @.CurrentEstimate + 1,
--keep the other predecessors as well
#UserList.Predecessor = replace(@.FromUserName, ' ', '')+','+#UserList.Predecessor,
#UserList.PredecessorCodes = replace(str(@.FromUser), ' ', '')+','+#UserList.PredecessorCodes
FROM #UserList INNER JOIN tblFriends ON #UserList.UserCode = tblFriends.UserCodeFriend
WHERE tblFriends.UserCodeOwner = @.FromUser AND (@.CurrentEstimate + 1) <= #UserList.Estimate
END

SELECT ud1.UserName AS UserNameFriend,ud1.UserCode, Estimate AS Distance, PredecessorCodes, Predecessor
FROM #UserList
INNER JOIN tblUserData ud1 ON #UserList.UserCode = ud1.UserCode
WHERE #UserList.Estimate<=@.MaxDistance AND #UserList.Estimate>=@.MinDistance
ORDER BY Distance ASC

-- Drop the temp table.
DROP TABLE #UserList

COMMIT TRAN

END

Check if this helps:http://hansolav.net/blog/CommentView,guid,1dfcc780-268a-415e-ae1f-aa20f370677e.aspx|||thats what I derived my sp from in the first place :)sql

Sunday, March 11, 2012

Differential Backup via Maintenance wizard

(If this is not the correct forum please point me in the right direction)

I am trying to schedule a Daliy differential backup using the Maintenance Wizard. This works fine for me, however I do not see where I can actualy speficy the file name I want to use for the differential backup

I notice that SQL 2005 will add the date and time for example MyDatabase_backup_200703191330. I would like to use a different name, for example MyDatabase_DiffBackup_DateTime. How can I specify this, I am not able to modify the T-SQL that is generated. is there a way to do this? Modify the T-SQL

Do I need to specify "backup databases across one or more files option" if so where do i specify the file name.

Should I create the job manually and execute to a T-SQL statement where I can specify the file name?

Thanks

-javahar

Create a Job and write T-SQL Code for Differential Backup will be great and less problem

Thanks

Faiz Farazi

www.databasetimes.net

Best learning center for Microsoft

http://www.lascomp.com

Friday, February 24, 2012

Different Display based on Text

I have an HTMP form and for some reason, when I use a regular TextBox to display a field, Via an ASP conneciton to the database, it cuts it off when it gets to a " (A quote)

Example:

Field: Title
Data: Where do "rabbits" come from?

If I try to pull that field into a regular html textbox it dispays,

Where do

Then if I change the textbox to a textarea it displays the entire field

Where do "rabbits" come from?

Is this a setting that causes this in SQL Server on the table.

I am new to SQL Server and am trying to learn these little differences.

Any help would be greatly appreciated.

Thanks,Sounds like an ASP problem. SQL is ignorant of how you are displaying the data.

Perhaps you need to double the quotes when using a textbox?

--> Where do ""rabbits"" come from?

Just guessing.|||Then the quotes get saved as double when you display the field in a different manner.

Tuesday, February 14, 2012

Differences between subscription types - help needed

I'm attempting to learn about Data Driven Subscriptions via Books
Online, particularly this tutorial:
http://msdn2.microsoft.com/en-us/library/ms169673.aspx, with no luck
thus far.
I have created essentially the same subscription as a non-data driven
one, and this successfully creates the file (rather than the email
mentioned in the tutorial). What could cause a data-driven subscription
not to work when an almost identical regular subscription does work? I
have tried both methods multiple times, with the same results.
Thanks in advance.This problem has been resolved. The local copy of that tutorial is
outdated, with the new version online. It makes values for a few fields
more explicit, and explores writing to a fileshare rather than to
email.