I have this code to copy files from one location to another in Access 2010 and is working fine. The problem I'm having is copying just the new files to the destination. I do not want to override the files, only copy new files.
Here is my code:
Public Declare Function SHFileOperation Lib "shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_COPY = &H2
Private Const FO_DELETE = &H3
Private Const FO_MOVE = &H1
Private Const FO_RENAME = &H4
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_CONFIRMMOUSE = &H2
Private Const FOF_CREATEPROGRESSDLG = &H0
Private Const FOF_FILESONLY = &H80
Private Const FOF_MULTIDESTFILES = &H1
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_NOCONFIRMMKDIR = &H200
Private Const FOF_RENAMEONCOLLISION = &H8
Private Const FOF_SILENT = &H4
Private Const FOF_SIMPLEPROGRESS = &H100
Private Const FOF_WANTMAPPINGHANDLE = &H20
Public Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type
Public Sub VBCopyFolder(ByRef strSource As String, ByRef strTarget As String)
Dim op As SHFILEOPSTRUCT
With op
.wFunc = FO_COPY
.pTo = strTarget
.pFrom = strSource
.fFlags = FOF_SIMPLEPROGRESS
End With
'~~> Perform operation
SHFileOperation op
End Sub
I call the subroutine like so
Call VBCopyFolder("O:\fieldticket\pdf\", "\\rwmain01\gis\FieldTicket\")
Here is one option you can try. You will have to iterate through the files though. So, it will potentially be slow over time if you have a large number of files building up.
Public Sub CopyFiles()
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim fils As Scripting.Files
Dim fil As Scripting.File
Dim strSourceFolder As String
Dim strDestFolder As String
Dim strFileName As String
On Error GoTo err_Proc
Set fso = CreateObject("Scripting.FileSystemObject")
strSourceFolder = "O:\fieldticket\pdf\"
strDestFolder = "\\rwmain01\gis\FieldTicket\"
If Not fso.FolderExists(strSourceFolder) Then GoTo exit_Proc
Set fld = fso.GetFolder(strSourceFolder)
For Each fil In fld.Files
' Process the file with logic you consider new
If fil.DateCreated > Now - 1 Then
fso.CopyFile fil.Path, strDestFolder & fil.Name
DoEvents
End If
' Or just try to copy it over with overwrite set to false
'fso.CopyFile fil.Path, strDestFolder & fil.Name, False
Next
exit_Proc:
Set fil = Nothing
Set fils = Nothing
Set fld = Nothing
Set fso = Nothing
Exit Sub
err_Proc:
Debug.Print Err.Description
GoTo exit_Proc
End Sub
Related
I have an ssis package with an existing vb script task to send emails.
I am rewriting it in c#.
The vb version works, the c# version doesn't but it doesn't fail or error either, that I can see.
If I put a breakpoint in both, when I run the package to debug, it breaks in the vb script but not the c# script.
I have included the code for each below.
They are very similar so I am wondering if there is a task setting that controls this that I am overlooking.
Thanks in advance
The vb script is as follows.
...
Public Sub Main()
Dim htmlMessageFrom As String = Dts.Variables("SSISErrorEmailFrom").Value.ToString
Dim htmlMessageTo As String = Dts.Variables("SSISErrorEmailTo").Value.ToString
Dim htmlMessageSubject As String = Dts.Variables("SSISErrorEmailSubject").Value.ToString
Dim htmlMessageBody As String = Dts.Variables("SSISErrorEmailBody").Value.ToString
Dim SSISErrorTable As String = Dts.Variables("SSISErrorTable").Value.ToString
Dim smtpConnectionString As String = DirectCast(Dts.Connections("SMTP Connection").AcquireConnection(Dts.Transaction), String)
Dim smtpServer As String = "smtprelay.white01.babcockgroup.co.uk"
htmlMessageBody = htmlMessageBody.Replace("###subject###", htmlMessageSubject)
htmlMessageBody = htmlMessageBody.Replace("###SSISErrorTable###", SSISErrorTable)
SendMailMessage(
htmlMessageFrom, htmlMessageTo,
htmlMessageSubject, htmlMessageBody,
True, smtpServer)
Dts.TaskResult = ScriptResults.Success
End Sub
Private Sub SendMailMessage(
ByVal From As String, ByVal SendTo As String,
ByVal Subject As String, ByVal Body As String,
ByVal IsBodyHtml As Boolean, ByVal Server As String)
Dim htmlMessage As MailMessage
Dim mySmtpClient As SmtpClient
htmlMessage = New MailMessage(
From, SendTo, Subject, Body)
htmlMessage.IsBodyHtml = IsBodyHtml
mySmtpClient = New SmtpClient(Server)
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
mySmtpClient.Send(htmlMessage)
End Sub
...
The c# scipt is as follows
...
public void Main()
{
sendEmail();
}
private void sendEmail()
{
var noBytes = new byte[0];
// TODO: Add your code here
try
{
string SSISErrorEmailTo = Dts.Variables["SSISErrorEmailTo"].Value.ToString();
string SSISErrorEmailFrom = Dts.Variables["SSISErrorEmailFrom"].Value.ToString();
string SSISErrorEmailSubject = Dts.Variables["SSISErrorSubject"].Value.ToString();
string SSISErrorEmailBody = Dts.Variables["SSISErrorEmailBody"].Value.ToString();
string SSISErrorTable = Dts.Variables["SSISErrorTable"].Value.ToString();
SSISErrorEmailBody.Replace("###subject###", SSISErrorEmailSubject);
SSISErrorEmailBody.Replace("###SSISErrorTable###", SSISErrorTable);
string SmtpServer = "smtprelay.white01.babcockgroup.co.uk";
MailMessage msg = new MailMessage(SSISErrorEmailFrom, SSISErrorEmailTo, SSISErrorEmailSubject, SSISErrorEmailBody);
msg.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient(SmtpServer);
smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
smtpClient.Send(msg);
Dts.TaskResult = (int)ScriptResults.Success;
Dts.Log("OnError script completed", -1, noBytes);
}
catch (Exception e)
{
Dts.TaskResult = (int)ScriptResults.Failure;
Dts.Log(e.InnerException.Message, -1, noBytes);
}
}
...
Have an Access Database that has been upgraded from 2007 32bit to Access 2016 64 bit.
In the one from there is a button to import a csv file for the data.
In the old version it would let you choose the file, but that doesn't work on 2016. This is the vba code for this action that worked in access 2007 32bit version.
Type tagOPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
strFilter As String
strCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
strFile As String
nMaxFile As Long
strFileTitle As String
nMaxFileTitle As Long
strInitialDir As String
strTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
strDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare PtrSafe Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
Global Const ahtOFN_READONLY = &H1
Global Const ahtOFN_OVERWRITEPROMPT = &H2
Global Const ahtOFN_HIDEREADONLY = &H4
Global Const ahtOFN_NOCHANGEDIR = &H8
Global Const ahtOFN_SHOWHELP = &H10
' You won't use these.
'Global Const ahtOFN_ENABLEHOOK = &H20
'Global Const ahtOFN_ENABLETEMPLATE = &H40
'Global Const ahtOFN_ENABLETEMPLATEHANDLE = &H80
Global Const ahtOFN_NOVALIDATE = &H100
Global Const ahtOFN_ALLOWMULTISELECT = &H200
Global Const ahtOFN_EXTENSIONDIFFERENT = &H400
Global Const ahtOFN_PATHMUSTEXIST = &H800
Global Const ahtOFN_FILEMUSTEXIST = &H1000
Global Const ahtOFN_CREATEPROMPT = &H2000
Global Const ahtOFN_SHAREAWARE = &H4000
Global Const ahtOFN_NOREADONLYRETURN = &H8000
Global Const ahtOFN_NOTESTFILECREATE = &H10000
Global Const ahtOFN_NONETWORKBUTTON = &H20000
Global Const ahtOFN_NOLONGNAMES = &H40000
' New for Windows 95
Global Const ahtOFN_EXPLORER = &H80000
Global Const ahtOFN_NODEREFERENCELINKS = &H100000
Global Const ahtOFN_LONGNAMES = &H200000
Private Sub cmdImportStudents_Click()
Dim strDirFile As String
strDirFile = GetOpenFile(CurrentDb().Name, "Select Student Import File")
If strDirFile > "" Then
Dim strA1 As String
'---
Open strDirFile For Input As #1
'---
If EOF(1) Then
Close #1
GoTo ErrorImportStudents
Else
'---
Line Input #1, strA1
Close #1
'--- Delete destination table ---
On Error Resume Next
DoCmd.DeleteObject acTable, "STUD_REC"
'--- Import data ---
On Error GoTo ErrorImportStudents
DoCmd.TransferText acImportDelim, "Students (comma)", "STUD_REC", strDirFile
End If
End If
MsgBox "Import Complete!", , "Student Import"
ExitImportStudents:
Exit Function
ErrorImportStudents:
MsgBox "Error(s) occured during 'Student' import!"
Resume ExitImportStudents
End Function
Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click
DoCmd.Close
Exit_cmdExit_Click:
Exit Sub
Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click
End Sub
Anytime I scan a fingerprint for verification I get the message "Fingerprint not verified" even though I have already enrolled that fingerprint into the database. Here is the code for capture when the form loads
Here is the code for capture when the form loads
Private Sub Me_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Init()
StartCapture()
Dim conn As New MySqlConnection
Dim cmd As New MySqlCommand
Dim sql As String
conn.ConnectionString = "**** "
conn.Open()
sql = ("SELECT * FROM new_case_file")
cmd.Connection = conn
cmd.CommandText = sql
Dim rdr As MySqlDataReader = cmd.ExecuteReader()
While (rdr.Read())
Dim MemStream As IO.MemoryStream
Dim fpBytes As Byte()
fpBytes = rdr("FingerPrint")
MemStream = New IO.MemoryStream(fpBytes)
Dim templa8 As DPFP.Template = New DPFP.Template()
templa8.DeSerialize(MemStream)
Dim serializedTemplate As Byte() = MemStream.ToArray
Dim tmpObj As New AppData
Dim FPList As List(Of AppData) = New List(Of AppData)
'tmpObj.No = rdr("No").ToString()
'tmpObj.Template = templa8
'FPList.Add(tmpObj)
End While
conn.Close()
End Sub
Here is the code for verification. When l click on the button it should verify, because l called the sub verifyControl_Commplete in the button click sub.
Private Sub verifyControl_OnComplete(ByVal Control As Object, ByVal FeatureSet As DPFP.FeatureSet, ByRef EventHandlerStatus As
DPFP.Gui.EventHandlerStatus) Handles verifyControl.OnComplete
Dim printFound As Boolean = False
'Dim printFound As Boolean = True
'Dim printFound As Boolean = False
Dim VerifiedFPData = New AppData
Dim FPList As List(Of AppData) = New List(Of AppData)
Try
For Each FPData As AppData In FPList
Dim tmplateData As New DPFP.Template
'tmplateData = FPData.Template
Dim compareTo As New DPFP.FeatureSet
compareTo = FeatureSet
Dim ver As New DPFP.Verification.Verification()
Dim res As New DPFP.Verification.Verification.Result()
If Not tmplateData Is Nothing Then
ver.Verify(FeatureSet, tmplateData, res)
If res.Verified Then
EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Success
printFound = True
VerifiedFPData = FPData
Exit For
End If
End If
Next
Catch ex As Exception
MessageBox.Show("Error")
End Try
If printFound Then
MsgBox("Verified")
Else
EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Failure
MsgBox("Not Verified")
End If
End Sub
Private Sub btnverifyfp_Click(sender As Object, e As EventArgs) Handles btnverifyfp.Click
verifyControl_OnComplete(Nothing, Nothing, Nothing)
End Sub
This is the code l used in saving the fingerprint
Dim fingerprintData As MemoryStream = New MemoryStream
Enroller.Template.Serialize(fingerprintData)
Dim serializedTemplate As Byte() = fingerprintData.ToArray()
Dim bytes() As Byte = serializedTemplate
Try this:
'THIS NEEDS TO BE AT THE CLASS-LEVEL, AS A MEMBER
Private FPList As New List(Of AppData)
Private Sub Me_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs)
Handles MyBase.Load
Init()
StartCapture()
Dim sql As String = "SELECT * FROM new_case_file"
Using conn As New MySqlConnection("**** "), _
cmd As New MySqlCommand(sql, conn)
conn.Open()
Using rdr As MySqlDataReader = cmd.ExecuteReader()
FPList.Clear()
While (rdr.Read())
Dim tmpObj As New AppData
tmpObj.No = rdr("No").ToString()
Dim fpBytes As Byte() = rdr("FingerPrint")
Using MemStream As New IO.MemoryStream(fpBytes)
Dim templa8 As New DPFP.Template()
templa8.DeSerialize(MemStream)
End Using
tmpObj.Template = templa8
FPList.Add(tmpObj)
End While
rdr.Close()
End Using
End Using
End Sub
And now other code later can use that same FPList variable. If you find yourself writing New List(Of AppData) anywhere else, you're doing something wrong.
The AppData class should look something like this:
Public Class AppData
Public Property No As String
Public Property Template As DFFP.Template
End Class
And finally, the verify code:
Private Sub verifyControl_OnComplete(ByVal Control As Object, ByVal FeatureSet As DPFP.FeatureSet,
ByRef EventHandlerStatus As DPFP.Gui.EventHandlerStatus)
Handles verifyControl.OnComplete
Try
Dim ver As New DPFP.Verification.Verification()
Dim res As New DPFP.Verification.Verification.Result()
For Each FPData As AppData In FPList
If FPData.Template Is Nothing Then Continue
ver.Verify(FeatureSet, FPData.Template, res)
If res.Verified Then
EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Success
MsgBox("Verified")
Return
End If
Next FPDAta
Catch ex As Exception
MessageBox.Show("Error")
End Try
EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Failure
MsgBox("Not Verified")
End Sub
Again... we don't have access to your API documentation, test data, or equipment. That means we're blind trying to help you here. There's probably some things wrong with this, and you'll have to be able to troubleshoot and debug.
Saving an Excel workbook to HTML is not working properly in Windows 10. It is working fine in Windows 7.
Code:
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application = New Microsoft.Office.Interop.Excel.Application()
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
xlWorkSheet.Cells(1, 1) = "Sheet 1 content"
xlWorkBook.SaveAs(Filename:="C:\Test\csharp-Excel.htm", FileFormat:=Excel.XlFileFormat.xlHtml, Password:="", _
WriteResPassword:="", ReadOnlyRecommended:=True, CreateBackup:=False)
xlApp.Quit()
releaseObject(xlWorkSheet)
releaseObject(xlWorkBook)
releaseObject(xlApp)
MessageBox.Show("Excel file created successfully")
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
End Class
Here is the Code:
VB:
Imports System.Web.Script.Serialization
Partial Class MyLanding
Inherits System.Web.UI.Page
Private LoginClass As New LoginClass
Private _dockStateCleared As Boolean = False
Private _conn As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)
Private ReadOnly Property CurrentDockStates() As List(Of DockState)
Get
'Get saved state string from the database - set it to dockState variable for example
Dim dockStatesFromDB As String = ""
_conn.Open()
Dim command As New SqlCommand("SELECT JavascriptStr FROM SysProperties WHERE (UserID = #UserID)", _conn)
command.Parameters.Add("#UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
Try
dockStatesFromDB = command.ExecuteScalar().ToString()
_conn.Close()
Catch ex As Exception
_conn.Close()
Me.CreateSavedLayout("")
End Try
Dim _currentDockStates As New List(Of DockState)()
Dim stringStates As String() = dockStatesFromDB.Split("|"c)
For Each stringState As String In stringStates
If stringState.Trim() <> String.Empty Then
_currentDockStates.Add(DockState.Deserialize(stringState))
End If
Next
Return _currentDockStates
End Get
End Property
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
If Not Page.IsPostBack Then
If CurrentDockStates.Count = 0 Then
Me.LoadItems()
End If
End If
End Sub
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
Dim i As Integer = 0
While i < CurrentDockStates.Count
If CurrentDockStates(i).Closed = False Then
Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i))
dlColumnOne.Controls.Add(dock)
CreateSaveStateTrigger(dock)
LoadUserControl(dock)
End If
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
End Sub
Protected Sub dlColumnOne_LoadDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
For Each state As DockState In CurrentDockStates
e.Positions(state.UniqueName) = state.DockZoneID
e.Indices(state.UniqueName) = state.Index
Next
End Sub
Protected Sub dlColumnOne_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
Dim stateList As List(Of DockState) = dlColumnOne.GetRegisteredDocksState()
Dim serializedList As New StringBuilder()
Dim i As Integer = 0
While i < stateList.Count
serializedList.Append(stateList(i).ToString())
serializedList.Append("|")
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
Dim dockState As String = serializedList.ToString()
If dockState.Trim() <> [String].Empty Then
_conn.Open()
Dim command As New SqlCommand([String].Format("update sysproperties set javascriptstr = '{0}' Where UserID = #UserID ", dockState), _conn)
command.Parameters.Add("#UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
command.ExecuteNonQuery()
_conn.Close()
End If
End Sub
Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock
Dim dock As New RadDock()
dock.DockMode = DockMode.Docked
dock.UniqueName = state.UniqueName
dock.ID = String.Format("RadDock{0}", dock.UniqueName)
dock.ApplyState(state)
dock.Commands.Add(New DockCloseCommand())
dock.Commands.Add(New DockExpandCollapseCommand())
Return dock
End Function
Private Function CreateRadDock(ByVal DockTitle As String) As RadDock
Dim docksCount As Integer = CurrentDockStates.Count
Dim dock As New RadDock
dock.DockMode = DockMode.Docked
Dim UniqueName As String = Guid.NewGuid().ToString()
UniqueName = UniqueName.Replace("-", "")
dock.UniqueName = UniqueName
dock.ID = String.Format("RadDock{0}", UniqueName)
dock.Title = DockTitle
dock.Width = Unit.Pixel(400)
dock.Commands.Add(New DockCloseCommand())
dock.Commands.Add(New DockExpandCollapseCommand())
Return dock
End Function
Private Sub LoadItems()
Dim DocksDataTable As DataTable = Me.ReturnReports()
For i = 0 To DocksDataTable.Rows.Count() - 1
Dim dock As RadDock = Me.CreateRadDock(DocksDataTable.Rows(i).Item("ReportTitle").ToString())
Dim dz As RadDockZone = Me.dzColumnOne
Dim dl As RadDockLayout = Me.dlColumnOne
dz.Controls.Add(dock)
Me.CreateSaveStateTrigger(dock)
dock.Tag = DocksDataTable.Rows(i).Item("ReportPath")
Me.LoadUserControl(dock)
Next
End Sub
Public Function ReturnReports() As DataTable
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)
Dim Query As String = "SELECT Reports.ReportPath, Reports.ReportTitle, UserReports.UserID FROM UserReports INNER JOIN Reports ON UserReports.ReportID = Reports.ReportID WHERE (UserReports.UserID = #UserID)"
Dim adapter As New SqlDataAdapter
adapter.SelectCommand = New SqlCommand(Query, connection)
adapter.SelectCommand.Parameters.Add("#UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
Dim table1 As New DataTable
connection.Open()
Try
adapter.Fill(table1)
Finally
connection.Close()
End Try
Return table1
End Function
Private Function ReturnLayout() As DataTable
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)
Dim Query As String = "select * from sysproperties"
Dim adapter As New SqlDataAdapter
adapter.SelectCommand = New SqlCommand(Query, connection)
adapter.SelectCommand.Parameters.Add("#UserPropertiesID", SqlDbType.Int).Value = 1
Dim table1 As New DataTable
connection.Open()
Try
adapter.Fill(table1)
Finally
connection.Close()
End Try
Return table1
End Function
Private Sub LoadUserControl(ByVal dock As RadDock)
If String.IsNullOrEmpty(dock.Tag) Then
Return
End If
Dim usercontrol As Control = LoadControl(dock.Tag)
dock.ContentContainer.Controls.Add(usercontrol)
End Sub
Private Sub CreateSaveStateTrigger(ByVal dock As RadDock)
dock.AutoPostBack = True
dock.CommandsAutoPostBack = True
Dim saveStateTrigger As New AsyncPostBackTrigger()
saveStateTrigger.ControlID = dock.ID
saveStateTrigger.EventName = "DockPositionChanged"
UpdatePanel1.Triggers.Add(saveStateTrigger)
saveStateTrigger = New AsyncPostBackTrigger()
saveStateTrigger.ControlID = dock.ID
saveStateTrigger.EventName = "Command"
UpdatePanel1.Triggers.Add(saveStateTrigger)
End Sub
Private Sub CreateSavedLayout(ByVal JavascriptStr As String)
Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)
Dim strSqlInsert As String = "INSERT INTO SysProperties(UserID, JavascriptStr) VALUES (#UserID, #JavascriptStr)"
strSqlInsert += "; SELECT SCOPE_IDENTITY() ;"
Dim sqlCmd As New SqlCommand(strSqlInsert, sqlConn)
With sqlCmd.Parameters
.Add("#JavascriptStr", SqlDbType.Text).Value = JavascriptStr
.Add("#UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
End With
sqlCmd.Connection.Open()
sqlCmd.ExecuteScalar()
sqlCmd.Connection.Close()
End Sub
Protected Sub btnAddReports_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddReports.Click
Try
Response.Redirect("~/MyUserAccount/SelectedReports.aspx", False)
Catch ex As Exception
End Try
End Sub
End Class
Your could looks fine. Possible reasons for this problem include the following:
Dragging the Dock control very quickly causes an ajax conflict, and an error is shown. To avoid this from happening you could show an AjaxLoading panel during the process of an ajax request (search/ask in the telerik forums for a sample showing how to do this). Additionally you should make sure the UpdatePanels on your site are configured as in the following online demo: http://demos.telerik.com/aspnet-ajax/dock/examples/myportal/defaultcs.aspx.
The error is a result of a ViewState problem. This telerik forum thread provides a possible solution: www.telerik.com/community/forums/aspnet-ajax/docking/failed-to-load-view-state-error-when-moving-dynamically-created-widgets-around-the-raddocklayout.aspx