Private Sub GetDataFromMagicZoomControls()
Dim DisableZoomEffect As String
Dim DisableExpandEffect As String
Dim OpacityReverse As String
Dim ShowThumbnailWhenImageExpanded As String
Dim FitZoomWindow As String
Dim EntireImage As String
Dim PanZoom As String
Dim RestartSlideshowAfterLastImage As String
Dim ClickToActivate As String
Dim ClickToDeactivate As String
Dim Smoothing As String
Dim ZoomFade As String
Dim DragMode As String
Dim MoveOnClick As String
Dim PreservePosition As String
Dim LoadingMessage As String
Dim hint As String
Try
Dim dt As New DataTable("ZoomPlusSetting")
dt.Columns.Add("SettingsKey")
dt.Columns.Add("SettingsValue")
Dim dRow As DataRow = Nothing
If ddlDisableZoom.SelectedItem.Text.ToLower() = "yes" Then
DisableZoomEffect = "true"
Else
DisableZoomEffect = "false"
End If
If ddldisableExpand.SelectedItem.Text.ToLower() = "yes" Then
DisableExpandEffect = "true"
Else
DisableExpandEffect = "false"
End If
dt.Rows.Add("DisableZoomEffect", DisableZoomEffect)
dt.Rows.Add("DisableExpandEffect", DisableExpandEffect)
dt.Rows.Add("ShowRightClickMenuOnTheImage", ddlRightClick.SelectedItem.Text)
dt.Rows.Add("ZoomWidth", txtZoomWidth.Text)
dt.Rows.Add("ZoomHeight", txtZoomHeight.Text)
dt.Rows.Add("ZoomPosition", ddlZoomPosition.SelectedItem.Text)
dt.Rows.Add("ZoomDistance", txtZoomDistance.Text)
dt.Rows.Add("ZoomAlign", ddlZoomAlign.SelectedItem.Text)
dt.Rows.Add("SizeOfTheExpandedImage", ddlExpandSize.SelectedItem.Text)
If ddlExpandSize.SelectedItem.Value = "width" OrElse ddlExpandSize.SelectedItem.Value = "height" Then
dt.Rows.Add("SizeOfTheExpandedImageWidthHeight", txtExpandSizeEx.Text)
Else
dt.Rows.Add("SizeOfTheExpandedImageWidthHeight", "")
End If
dt.Rows.Add("AlignExpandedImageRelativeTo", ddlExpandAlign.SelectedItem.Text)
dt.Rows.Add("PrecisePositionOfExpandedImage", txtExpandPosition.Text)
dt.Rows.Add("Opacity", txtopacity.Text)
If chkOpacityReverse.Checked Then
OpacityReverse = "true"
Else
OpacityReverse = "false"
End If
If chksmoothing.Checked Then
Smoothing = "true"
Else
Smoothing = "false"
End If
dt.Rows.Add("OpacityReverse", OpacityReverse)
dt.Rows.Add("Smoothing", Smoothing)
dt.Rows.Add("SmoothingSpeed", txtSmoothingSpeed.Text)
If chkZoomFade.Checked Then
ZoomFade = "true"
Else
ZoomFade = "false"
End If
dt.Rows.Add("ZoomFade", ZoomFade)
dt.Rows.Add("ZoomFadeInSpeed", txtzoomFadeIn.Text)
dt.Rows.Add("ZoomFadeOutSpeed", txtzoomFadeOut.Text)
dt.Rows.Add("ZoomWindowEffect", ddlzoomWindowEffect.SelectedItem.Text)
dt.Rows.Add("ExpandDuration", txtExpandSpeed.Text)
dt.Rows.Add("RestoreDuration", txtRestoreSpeed.Text)
dt.Rows.Add("EffectForExpandingImage", ddlExpandEffect.SelectedItem.Text)
dt.Rows.Add("EffectForRestoringImage", ddlRestoreEffect.SelectedItem.Text)
If chkKeepThumbnail.Checked Then
ShowThumbnailWhenImageExpanded = "true"
Else
ShowThumbnailWhenImageExpanded = "false"
End If
dt.Rows.Add("ShowThumbnailWhenImageExpanded", ShowThumbnailWhenImageExpanded)
dt.Rows.Add("TriggerForTheExpandEffect", ddlExpandTrigger.SelectedItem.Text)
dt.Rows.Add("DelayBeforeMouseoverTriggersExpansion", txtexpandTriggerDelay.Text)
dt.Rows.Add("TriggerToRestoreImageToItsSmallState", ddlRestoreTrigger.SelectedItem.Text)
If chkDragMode.Checked Then
DragMode = "true"
Else
DragMode = "false"
End If
dt.Rows.Add("DragMode", DragMode)
If chkmoveOnClick.Checked Then
MoveOnClick = "true"
Else
MoveOnClick = "false"
End If
dt.Rows.Add("MoveOnClick", MoveOnClick)
If chkPreservePosition.Checked Then
PreservePosition = "true"
Else
PreservePosition = "false"
End If
dt.Rows.Add("PreservePosition", PreservePosition)
dt.Rows.Add("XInPx", txtX.Text)
dt.Rows.Add("YInPx", txtY.Text)
If chkfitZoomWindow.Checked Then
FitZoomWindow = "true"
Else
FitZoomWindow = "false"
End If
dt.Rows.Add("FitZoomWindow", FitZoomWindow)
If chkEntireImage.Checked Then
EntireImage = "true"
Else
EntireImage = "false"
End If
dt.Rows.Add("EntireImage", EntireImage)
If chkPanZoom.Checked Then
PanZoom = "true"
Else
PanZoom = "false"
End If
dt.Rows.Add("PanZoom", PanZoom)
dt.Rows.Add("VisualEffectForSwitchingExpandedImages", ddlSlideshowEffect.SelectedItem.Text)
dt.Rows.Add("SpeedOfSlideshowEffect", txtSlideshowSpeed.Text)
If chkSlideshowLoop.Checked Then
RestartSlideshowAfterLastImage = "true"
Else
RestartSlideshowAfterLastImage = "false"
End If
dt.Rows.Add("RestartSlideshowAfterLastImage", RestartSlideshowAfterLastImage)
dt.Rows.Add("SelectorsChange", ddlSelectorsChange.SelectedItem.Text)
dt.Rows.Add("SelectorsMouseoverDelay", txtSelectorsMouseoverDelay.Text)
dt.Rows.Add("SelectorsEffect", ddlSelectorsEffect.SelectedItem.Text)
dt.Rows.Add("SelectorsEffectSpeed", txtSelectorsEffectSpeed.Text)
If ddlhint.SelectedItem.Text = "Yes" Then
hint = "true"
Else
hint = "false"
End If
dt.Rows.Add("Hint", hint)
dt.Rows.Add("HintText", txtHintText.Text)
dt.Rows.Add("HintPosition", ddlHintPosition.SelectedItem.Value)
dt.Rows.Add("HintOpacity", txtHintOpacity.Text)
dt.Rows.Add("ShowTitle", ddlShowTitle.SelectedItem.Text)
dt.Rows.Add("SourceOfTheTitleText", ddlTitleSource.SelectedItem.Value)
dt.Rows.Add("SourceOfCaptionText", ddlCaptionSource.SelectedItem.Text)
dt.Rows.Add("SpeedOfCaptionSlideEffect", txtCaptionSpeed.Text)
dt.Rows.Add("WhereToPositionTheCaption", ddlCaptionPosition.SelectedItem.Text)
dt.Rows.Add("MaxHeightOfBottomCaption", txtmaxCaptionHeight.Text)
dt.Rows.Add("MaxWidthOfLeftRightCaption", txtmaxCaptionWidth.Text)
dt.Rows.Add("BackgroundColorBehindLargeImage", txtBackgroundColor.Text)
dt.Rows.Add("OpacityOfTheBackground", txtBackgroundOpacity.Text)
dt.Rows.Add("DurationOfBackgroundFade", txtBackgroundSpeed.Text)
dt.Rows.Add("InitializeMagicZoomPlus", ddlInitializeOn.SelectedItem.Text)
If chkClickToActivate.Checked Then
ClickToActivate = "true"
Else
ClickToActivate = "false"
End If
dt.Rows.Add("ClickToActivate", ClickToActivate)
If chkClickToDeactivate.Checked Then
ClickToDeactivate = "true"
Else
ClickToDeactivate = "false"
End If
dt.Rows.Add("ClickToDeactivate", ClickToDeactivate)
If chkShowLoading.Checked Then
LoadingMessage = "true"
Else
LoadingMessage = "false"
End If
dt.Rows.Add("LoadingMessage", LoadingMessage)
dt.Rows.Add("LoadingMessageText", txtLoadingMSG.Text)
dt.Rows.Add("WhetherOrNotToShowButtons", ddlButtons.SelectedItem.Text)
dt.Rows.Add("ButtonsPosition", ddlButtonsPosition.SelectedItem.Text)
dt.Rows.Add("WhichButtonsToShow", txtButtonsDisplay.Text)
dt.Rows.Add("PreviousButton", txtButtonPrevious.Text)
dt.Rows.Add("NextButton", txtButtonNext.Text)
dt.Rows.Add("CloseButton", txtButtonClose.Text)
dt.Rows.Add("ChooseSizeOfButtons", ddlButtonsSize.SelectedItem.Text)
'Added by Team7e for Issue#1633(#2).
If rbtn1.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "1")
ElseIf rbtn2.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "2")
ElseIf rbtn3.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "3")
ElseIf rbtn4.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "4")
ElseIf rbtn5.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "5")
ElseIf rbtn6.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "6")
ElseIf rbtn7.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "7")
End If
Dim result As String = String.Empty
Using sw As New StringWriter()
dt.WriteXml(sw)
result = sw.ToString()
End Using
MagicZoomPlusToolboxSettingsBO.UpdateZoomPlusSettings(result)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
=======================================================
Public Shared Sub UpdateZoomPlusSettings(ByVal result As String)
MagicZoomPlusToolboxSettingsDB.UpdateZoomPlusSettings(result)
End Sub
Using conn As New SqlConnection(ConnectionString)
conn.Open()
Dim cmd As New SqlCommand()
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spUpdateMagicZoomPlusSettings"
Dim param As New SqlParameter("@MyXML", SqlDbType.Xml)
param.Value = result
cmd.Parameters.Add(param)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
Dim exp As String = ex.Message
End Try
End Using
End Sub
=========================================================================
IF EXISTS ( SELECT *
FROM sysobjects
WHERE id = OBJECT_ID(N'[spUpdateMagicZoomPlusSettings]')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1 )
DROP PROC [spUpdateMagicZoomPlusSettings]
GO
CREATE PROCEDURE [dbo].[spUpdateMagicZoomPlusSettings] ( @MyXML XML )
AS
BEGIN
SET ARITHABORT ON
BEGIN TRY
BEGIN TRANSACTION
SELECT Zoom.detail.value('(SettingsKey/text())[1]',
'varchar(100)') AS SettingsKey ,
Zoom.detail.value('(SettingsValue/text())[1]',
'varchar(100)') AS SettingsValue
INTO #TMP
FROM @MyXML.nodes('/DocumentElement/ZoomPlusSetting') AS Zoom ( detail )
DECLARE @Count AS VARCHAR(20)
SET @Count = ( SELECT COUNT(*)
FROM dbo.MagicZoomPlusSettings
)
IF @Count <> 0
DELETE FROM dbo.MagicZoomPlusSettings
INSERT INTO dbo.MagicZoomPlusSettings
SELECT *
FROM #TMP
IF @@ERROR <> 0
-- There's an error b/c @ERROR is not 0, rollback
ROLLBACK
ELSE
COMMIT -- Success! Commit the transaction
END TRY
BEGIN CATCH
--EXECUTE usp_GetErrorInfo
END CATCH
END
GO
IF NOT EXISTS ( SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'MagicZoomPlusSettings' )
CREATE TABLE [dbo].[MagicZoomPlusSettings]
(
[SettingsKey] [nvarchar](80) NOT NULL ,
[SettingsValue] [text] NULL ,
CONSTRAINT [MagicZoommSettings_uq] UNIQUE NONCLUSTERED
( [SettingsKey] ASC )
WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY]
)
ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Dim DisableZoomEffect As String
Dim DisableExpandEffect As String
Dim OpacityReverse As String
Dim ShowThumbnailWhenImageExpanded As String
Dim FitZoomWindow As String
Dim EntireImage As String
Dim PanZoom As String
Dim RestartSlideshowAfterLastImage As String
Dim ClickToActivate As String
Dim ClickToDeactivate As String
Dim Smoothing As String
Dim ZoomFade As String
Dim DragMode As String
Dim MoveOnClick As String
Dim PreservePosition As String
Dim LoadingMessage As String
Dim hint As String
Try
Dim dt As New DataTable("ZoomPlusSetting")
dt.Columns.Add("SettingsKey")
dt.Columns.Add("SettingsValue")
Dim dRow As DataRow = Nothing
If ddlDisableZoom.SelectedItem.Text.ToLower() = "yes" Then
DisableZoomEffect = "true"
Else
DisableZoomEffect = "false"
End If
If ddldisableExpand.SelectedItem.Text.ToLower() = "yes" Then
DisableExpandEffect = "true"
Else
DisableExpandEffect = "false"
End If
dt.Rows.Add("DisableZoomEffect", DisableZoomEffect)
dt.Rows.Add("DisableExpandEffect", DisableExpandEffect)
dt.Rows.Add("ShowRightClickMenuOnTheImage", ddlRightClick.SelectedItem.Text)
dt.Rows.Add("ZoomWidth", txtZoomWidth.Text)
dt.Rows.Add("ZoomHeight", txtZoomHeight.Text)
dt.Rows.Add("ZoomPosition", ddlZoomPosition.SelectedItem.Text)
dt.Rows.Add("ZoomDistance", txtZoomDistance.Text)
dt.Rows.Add("ZoomAlign", ddlZoomAlign.SelectedItem.Text)
dt.Rows.Add("SizeOfTheExpandedImage", ddlExpandSize.SelectedItem.Text)
If ddlExpandSize.SelectedItem.Value = "width" OrElse ddlExpandSize.SelectedItem.Value = "height" Then
dt.Rows.Add("SizeOfTheExpandedImageWidthHeight", txtExpandSizeEx.Text)
Else
dt.Rows.Add("SizeOfTheExpandedImageWidthHeight", "")
End If
dt.Rows.Add("AlignExpandedImageRelativeTo", ddlExpandAlign.SelectedItem.Text)
dt.Rows.Add("PrecisePositionOfExpandedImage", txtExpandPosition.Text)
dt.Rows.Add("Opacity", txtopacity.Text)
If chkOpacityReverse.Checked Then
OpacityReverse = "true"
Else
OpacityReverse = "false"
End If
If chksmoothing.Checked Then
Smoothing = "true"
Else
Smoothing = "false"
End If
dt.Rows.Add("OpacityReverse", OpacityReverse)
dt.Rows.Add("Smoothing", Smoothing)
dt.Rows.Add("SmoothingSpeed", txtSmoothingSpeed.Text)
If chkZoomFade.Checked Then
ZoomFade = "true"
Else
ZoomFade = "false"
End If
dt.Rows.Add("ZoomFade", ZoomFade)
dt.Rows.Add("ZoomFadeInSpeed", txtzoomFadeIn.Text)
dt.Rows.Add("ZoomFadeOutSpeed", txtzoomFadeOut.Text)
dt.Rows.Add("ZoomWindowEffect", ddlzoomWindowEffect.SelectedItem.Text)
dt.Rows.Add("ExpandDuration", txtExpandSpeed.Text)
dt.Rows.Add("RestoreDuration", txtRestoreSpeed.Text)
dt.Rows.Add("EffectForExpandingImage", ddlExpandEffect.SelectedItem.Text)
dt.Rows.Add("EffectForRestoringImage", ddlRestoreEffect.SelectedItem.Text)
If chkKeepThumbnail.Checked Then
ShowThumbnailWhenImageExpanded = "true"
Else
ShowThumbnailWhenImageExpanded = "false"
End If
dt.Rows.Add("ShowThumbnailWhenImageExpanded", ShowThumbnailWhenImageExpanded)
dt.Rows.Add("TriggerForTheExpandEffect", ddlExpandTrigger.SelectedItem.Text)
dt.Rows.Add("DelayBeforeMouseoverTriggersExpansion", txtexpandTriggerDelay.Text)
dt.Rows.Add("TriggerToRestoreImageToItsSmallState", ddlRestoreTrigger.SelectedItem.Text)
If chkDragMode.Checked Then
DragMode = "true"
Else
DragMode = "false"
End If
dt.Rows.Add("DragMode", DragMode)
If chkmoveOnClick.Checked Then
MoveOnClick = "true"
Else
MoveOnClick = "false"
End If
dt.Rows.Add("MoveOnClick", MoveOnClick)
If chkPreservePosition.Checked Then
PreservePosition = "true"
Else
PreservePosition = "false"
End If
dt.Rows.Add("PreservePosition", PreservePosition)
dt.Rows.Add("XInPx", txtX.Text)
dt.Rows.Add("YInPx", txtY.Text)
If chkfitZoomWindow.Checked Then
FitZoomWindow = "true"
Else
FitZoomWindow = "false"
End If
dt.Rows.Add("FitZoomWindow", FitZoomWindow)
If chkEntireImage.Checked Then
EntireImage = "true"
Else
EntireImage = "false"
End If
dt.Rows.Add("EntireImage", EntireImage)
If chkPanZoom.Checked Then
PanZoom = "true"
Else
PanZoom = "false"
End If
dt.Rows.Add("PanZoom", PanZoom)
dt.Rows.Add("VisualEffectForSwitchingExpandedImages", ddlSlideshowEffect.SelectedItem.Text)
dt.Rows.Add("SpeedOfSlideshowEffect", txtSlideshowSpeed.Text)
If chkSlideshowLoop.Checked Then
RestartSlideshowAfterLastImage = "true"
Else
RestartSlideshowAfterLastImage = "false"
End If
dt.Rows.Add("RestartSlideshowAfterLastImage", RestartSlideshowAfterLastImage)
dt.Rows.Add("SelectorsChange", ddlSelectorsChange.SelectedItem.Text)
dt.Rows.Add("SelectorsMouseoverDelay", txtSelectorsMouseoverDelay.Text)
dt.Rows.Add("SelectorsEffect", ddlSelectorsEffect.SelectedItem.Text)
dt.Rows.Add("SelectorsEffectSpeed", txtSelectorsEffectSpeed.Text)
If ddlhint.SelectedItem.Text = "Yes" Then
hint = "true"
Else
hint = "false"
End If
dt.Rows.Add("Hint", hint)
dt.Rows.Add("HintText", txtHintText.Text)
dt.Rows.Add("HintPosition", ddlHintPosition.SelectedItem.Value)
dt.Rows.Add("HintOpacity", txtHintOpacity.Text)
dt.Rows.Add("ShowTitle", ddlShowTitle.SelectedItem.Text)
dt.Rows.Add("SourceOfTheTitleText", ddlTitleSource.SelectedItem.Value)
dt.Rows.Add("SourceOfCaptionText", ddlCaptionSource.SelectedItem.Text)
dt.Rows.Add("SpeedOfCaptionSlideEffect", txtCaptionSpeed.Text)
dt.Rows.Add("WhereToPositionTheCaption", ddlCaptionPosition.SelectedItem.Text)
dt.Rows.Add("MaxHeightOfBottomCaption", txtmaxCaptionHeight.Text)
dt.Rows.Add("MaxWidthOfLeftRightCaption", txtmaxCaptionWidth.Text)
dt.Rows.Add("BackgroundColorBehindLargeImage", txtBackgroundColor.Text)
dt.Rows.Add("OpacityOfTheBackground", txtBackgroundOpacity.Text)
dt.Rows.Add("DurationOfBackgroundFade", txtBackgroundSpeed.Text)
dt.Rows.Add("InitializeMagicZoomPlus", ddlInitializeOn.SelectedItem.Text)
If chkClickToActivate.Checked Then
ClickToActivate = "true"
Else
ClickToActivate = "false"
End If
dt.Rows.Add("ClickToActivate", ClickToActivate)
If chkClickToDeactivate.Checked Then
ClickToDeactivate = "true"
Else
ClickToDeactivate = "false"
End If
dt.Rows.Add("ClickToDeactivate", ClickToDeactivate)
If chkShowLoading.Checked Then
LoadingMessage = "true"
Else
LoadingMessage = "false"
End If
dt.Rows.Add("LoadingMessage", LoadingMessage)
dt.Rows.Add("LoadingMessageText", txtLoadingMSG.Text)
dt.Rows.Add("WhetherOrNotToShowButtons", ddlButtons.SelectedItem.Text)
dt.Rows.Add("ButtonsPosition", ddlButtonsPosition.SelectedItem.Text)
dt.Rows.Add("WhichButtonsToShow", txtButtonsDisplay.Text)
dt.Rows.Add("PreviousButton", txtButtonPrevious.Text)
dt.Rows.Add("NextButton", txtButtonNext.Text)
dt.Rows.Add("CloseButton", txtButtonClose.Text)
dt.Rows.Add("ChooseSizeOfButtons", ddlButtonsSize.SelectedItem.Text)
'Added by Team7e for Issue#1633(#2).
If rbtn1.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "1")
ElseIf rbtn2.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "2")
ElseIf rbtn3.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "3")
ElseIf rbtn4.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "4")
ElseIf rbtn5.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "5")
ElseIf rbtn6.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "6")
ElseIf rbtn7.Checked Then
dt.Rows.Add("SizeOfButtonsNumber", "7")
End If
Dim result As String = String.Empty
Using sw As New StringWriter()
dt.WriteXml(sw)
result = sw.ToString()
End Using
MagicZoomPlusToolboxSettingsBO.UpdateZoomPlusSettings(result)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
=======================================================
BO
-----Public Shared Sub UpdateZoomPlusSettings(ByVal result As String)
MagicZoomPlusToolboxSettingsDB.UpdateZoomPlusSettings(result)
End Sub
DB
----
Public Shared Sub UpdateZoomPlusSettings(ByVal result As String)Using conn As New SqlConnection(ConnectionString)
conn.Open()
Dim cmd As New SqlCommand()
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spUpdateMagicZoomPlusSettings"
Dim param As New SqlParameter("@MyXML", SqlDbType.Xml)
param.Value = result
cmd.Parameters.Add(param)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
Dim exp As String = ex.Message
End Try
End Using
End Sub
=========================================================================
Stored procedure
----------------------IF EXISTS ( SELECT *
FROM sysobjects
WHERE id = OBJECT_ID(N'[spUpdateMagicZoomPlusSettings]')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1 )
DROP PROC [spUpdateMagicZoomPlusSettings]
GO
CREATE PROCEDURE [dbo].[spUpdateMagicZoomPlusSettings] ( @MyXML XML )
AS
BEGIN
SET ARITHABORT ON
BEGIN TRY
BEGIN TRANSACTION
SELECT Zoom.detail.value('(SettingsKey/text())[1]',
'varchar(100)') AS SettingsKey ,
Zoom.detail.value('(SettingsValue/text())[1]',
'varchar(100)') AS SettingsValue
INTO #TMP
FROM @MyXML.nodes('/DocumentElement/ZoomPlusSetting') AS Zoom ( detail )
DECLARE @Count AS VARCHAR(20)
SET @Count = ( SELECT COUNT(*)
FROM dbo.MagicZoomPlusSettings
)
IF @Count <> 0
DELETE FROM dbo.MagicZoomPlusSettings
INSERT INTO dbo.MagicZoomPlusSettings
SELECT *
FROM #TMP
IF @@ERROR <> 0
-- There's an error b/c @ERROR is not 0, rollback
ROLLBACK
ELSE
COMMIT -- Success! Commit the transaction
END TRY
BEGIN CATCH
--EXECUTE usp_GetErrorInfo
END CATCH
END
GO
IF NOT EXISTS ( SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'MagicZoomPlusSettings' )
CREATE TABLE [dbo].[MagicZoomPlusSettings]
(
[SettingsKey] [nvarchar](80) NOT NULL ,
[SettingsValue] [text] NULL ,
CONSTRAINT [MagicZoommSettings_uq] UNIQUE NONCLUSTERED
( [SettingsKey] ASC )
WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY]
)
ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
No comments:
Post a Comment