Showing posts with label developing. Show all posts
Showing posts with label developing. Show all posts

Wednesday, March 28, 2012

Multiuser Databinding in SQL Server 2000?

Hi

I am developing one multi user application in windows environment using VC++ .NET with SQL Server 2000. How Can I create dataset for multi user data updating in my SQL Server 2000. Where I can get help and sample code?

Thanks

Jose

Jose,

The DataSet is an off-line data cache. The DataAdapter is used to submit the pending changes stored in the DataSet. In the DataAdapter's updating logic, you can specify your own concurrency options to control whether you want to use a "last in wins" approach with only the primary key column(s) in the WHERE clause, or use other columns in the WHERE clause to ensure you don't overwrite changes made by another user.

I hope this information proves helpful.

David Sceppa
ADO.NET Program Manager
Microsoft|||Hi

Thankyou for the nice explanation. One more question how can I write custom primary key value. for example (50710000001) like this. 5 is for year, 07 is for month, 10 is for place, and remaining is unique automatic generating number. How can I write program in SQL Server 2000.

Regards,
Jose

Monday, March 19, 2012

Multiple users logging into a database

I'm developing an application in ASP.Net that uses SQLServer. The database person in the team wants to have each user have a seperate login to the database so he can tell who has done what changes in the database. Is this a good practice? Or are their performance\security issues with this model?For system performance it is better to use one account (to use one connection string) and connection pooling. My solution is as follows. Create your own users and log-in system. You can save current username or id to Session. Then create a table system_events to your database. Everytime user makes something you can insert a new row that describes user action. Also, and it is maybe even better, you can use plain text logs for this.|||We implemented this feature and what we did was write a stored procedure to check the old value against the new values being updated in the database and then it writes only the changes to a seperate table designed for tracking changes. We then wrote a page to display change history by date range in a D-Grid. It works very well and there has been no noticable performance hit since implementation.

CREATE PROCEDURE AddChangeHistory
(
@.propertyID INT,
@.userName VARCHAR(75), --Assigned in session when a user logins
@.tableName VARCHAR(75),
@.fieldName VARCHAR(80),
@.fieldChangeVal varchar(200)
)

AS

DECLARE @.fieldInitVal varchar(200)

BEGIN TRAN
CREATE TABLE #tempVal
(
fieldInitVal VARCHAR(200)
)

INSERT INTO #tempVal exec('SELECT TOP 1 ' + @.fieldName + ' FROM ' + @.tableName + ' WHERE propertyID=' + @.propertyID + '')

SELECT @.fieldInitVal = (SELECT top 1 * FROM #tempVal)

DROP TABLE #tempVal

IF(LOWER(@.fieldInitVal) <> LOWER(@.fieldChangeVal))
BEGIN
INSERT INTO ChangeHistory(propertyID, userName, tableName, fieldName, fieldInitVal, fieldChangeVal)
VALUES (@.propertyID, @.userName, @.tableName, @.fieldName, @.fieldInitVal, @.fieldChangeVal)
END

IF(@.@.ERROR <> 0)
BEGIN
ROLLBACK TRAN
END
ELSE
BEGIN
COMMIT TRAN
END
GO


SPROC to update my database
CREATE PROCEDURE dbo.oPK_UpdateAdminHours
(
@.Role AS varchar(100),
@.UserName AS varchar(100),
@.vcManager AS varchar(50),
@.vcAssistant1 AS varchar(50),
@.vcAssistant2 AS varchar(50),
@.vcLeasingManager AS varchar(50),
@.vcMarketingDirector AS varchar(50),
@.vcLeasing1 AS varchar(50),
@.vcLeasing2 AS varchar(50),
@.vcLeasing3 AS varchar(50),
@.vcLeasing4 AS varchar(50),
@.vcLeasing5 AS varchar(50),
@.bMon_Fri AS bit,
@.cDisplaySummer_Winter AS char(1),
@.vcOfficeHoursSummerMon AS varchar(25),
@.vcOfficeHoursWinterMon AS varchar(25),
@.vcOfficeHoursSummerTue AS varchar(25),
@.vcOfficeHoursWinterTue AS varchar(25),
@.vcOfficeHoursSummerWed AS varchar(25),
@.vcOfficeHoursWinterWed AS varchar(25),
@.vcOfficeHoursSummerThur AS varchar(25),
@.vcOfficeHoursWinterThur AS varchar(25),
@.vcOfficeHoursSummerFri AS varchar(25),
@.vcOfficeHoursWinterFri AS varchar(25),
@.vcOfficeHoursSummerSat AS varchar(25),
@.vcOfficeHoursWinterSat AS varchar(25),
@.vcOfficeHoursSummerSun AS varchar(25),
@.vcOfficeHoursWinterSun AS varchar(25),
@.vcTimeZone AS varchar(50),
@.PropertyID AS INT
)
AS
--Calling the AddChangeHistory SPROC to check the values before updating the Database
exec AddChangeHistory @.propertyID, @.userName, 'vcManager',@.vcManager
exec AddChangeHistory @.propertyID, @.userName, 'vcAssistant1',@.vcAssistant1
exec AddChangeHistory @.propertyID, @.userName, 'vcAssistant2',@.vcAssistant2
exec AddChangeHistory @.propertyID, @.userName, 'vcLeasingManager',@.vcLeasingManager
exec AddChangeHistory @.propertyID, @.userName, 'vcMarketingDirector',@.vcMarketingDirector
exec AddChangeHistory @.propertyID, @.userName, 'vcLeasing1',@.vcLeasing1
exec AddChangeHistory @.propertyID, @.userName, 'vcLeasing2',@.vcLeasing2
exec AddChangeHistory @.propertyID, @.userName, 'vcLeasing3',@.vcLeasing3
exec AddChangeHistory @.propertyID, @.userName, 'vcLeasing4',@.vcLeasing4
exec AddChangeHistory @.propertyID, @.userName, 'vcLeasing5',@.vcLeasing5
exec AddChangeHistory @.propertyID, @.userName, 'bMon_Fri',@.bMon_Fri
exec AddChangeHistory @.propertyID, @.userName, 'cDisplaySummer_Winter',@.cDisplaySummer_Winter
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursSummerMon',@.vcOfficeHoursSummerMon
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursWinterMon',@.vcOfficeHoursWinterMon
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursSummerTue',@.vcOfficeHoursSummerTue
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursWinterTue',@.vcOfficeHoursWinterTue
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursSummerWed',@.vcOfficeHoursSummerWed
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursWinterWed',@.vcOfficeHoursWinterWed
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursSummerThur',@.vcOfficeHoursSummerThur
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursWinterThur',@.vcOfficeHoursWinterThur
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursSummerFri',@.vcOfficeHoursSummerFri
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursWinterFri',@.vcOfficeHoursWinterFri
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursSummerSat',@.vcOfficeHoursSummerSat
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursWinterSat',@.vcOfficeHoursWinterSat
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursSummerSun',@.vcOfficeHoursSummerSun
exec AddChangeHistory @.propertyID, @.userName, 'vcOfficeHoursWinterSun',@.vcOfficeHoursWinterSun
exec AddChangeHistory @.propertyID, @.userName, 'vcTimeZone ',@.vcTimeZone

--Put your Update code here (removed for space)


Hope this helps.|||Thank you so much. That is what I needed.

Multiple types of data storing in SQL Server

Hello All,

We are developing customer support application. We will have so many customers after launching this product. But my problem is how will i store data of all these customers in SQL Server. Please suggest me.

You have not provided enough information about the nature of the problem for us to help you find a solution.

Wednesday, March 7, 2012

Multiple SQL Clusters on one EMC LUN?

Hello,
We have a Production SQL 2000 Cluster and are now developing on SQL 2K5 as
we plan to migrate shortly. We'll be introducing new hardware into
production with 2K5 installed. We would like to use a 'straddle migration'
method by utilizing both 2K and 2K5 in production at the same time and
moving services/websites/databases to 2K5 one at a time in case there are
any issues and we need to roll back over to 2K.
The question is how can we utilize the current LUNs/Cluster that's on the
EMC for the new 2K5 servers/cluster? Can we have a 2K and 2K5 cluster using
the same LUN? How would the Q: Quarum drive work? What possible
complications do see in this scenario?
Thank you in advance for your time,
Andew
If you do side by side, then you cannot use the same virtual server name,
instance name, IP address, or network port. Moreover, you will have to have
an independent dedicated disk(s) for the installation to even succeed.
Afterwards, however, you can use either detach/attach or database backups
and restores to migrate from one instance the next. If a rollback is called
for, you only have to point the connections back to the SS2K instance and
you're off and running again.
If your upgrade is successful, then you just uninstall the SS2K instance and
give storage back their original LUN for reuse.
What we typically do is restore pending the prior day's full database
backup, and then kick off a differential right before the migration. This
keeps the backup, transfer, restore window small during the migration
outage.
Sincerely,
Anthony Thomas

"Andrew Williams" <andrew.williams@.freedompay.com> wrote in message
news:99A9028F-DB5C-4E5F-9320-8BCA23F0C2B7@.microsoft.com...
> Hello,
> We have a Production SQL 2000 Cluster and are now developing on SQL 2K5 as
> we plan to migrate shortly. We'll be introducing new hardware into
> production with 2K5 installed. We would like to use a 'straddle
migration'
> method by utilizing both 2K and 2K5 in production at the same time and
> moving services/websites/databases to 2K5 one at a time in case there are
> any issues and we need to roll back over to 2K.
> The question is how can we utilize the current LUNs/Cluster that's on the
> EMC for the new 2K5 servers/cluster? Can we have a 2K and 2K5 cluster
using
> the same LUN? How would the Q: Quarum drive work? What possible
> complications do see in this scenario?
> Thank you in advance for your time,
>
> Andew
>
|||> Can we have a 2K and 2K5 cluster using
> the same LUN?
(assuming with LUN you mean physical disk resource in the cluster)
No, they need to be in there own dedicated cluster group with dedicated
physical disk resources

> How would the Q: Quarum drive work?
Quorum disk should be, together with cluster IP and cluster name and
possibly MSDTC, in it own cluster group, this is the *default* setup. No
changes for the Quorum disk
So you end up with:
cluster group - cluster resources (including Quorum disk)
group1 - SQL2K (with its own dedicated disks, IP, network name)
group2 - SQL2K5 (with its own dedicated disks, IP, network name)
does this answer your question ?
rgds,
edwin.