Aggiunti caratteri di escape se nel campo Note vengono inseriti i caratteri \, ', ", %

This commit is contained in:
RenzoL
2022-01-12 16:01:25 +01:00
parent 68bf33efae
commit 42e5788d40
7 changed files with 21 additions and 18 deletions
+2 -2
View File
@@ -260,7 +260,7 @@ Public Class NewKeyPageVM
" '" & m_LockID & "', " &
" '" & SelState.ToString() & "', " &
" '" & Format(KeyDate, "yyyy-MM-dd") & "', " &
" '" & m_Note & "', " &
" '" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "', " &
" '" & m_Seriale & "')"
Else
Query = "INSERT INTO " & DB_KEY & " (" & DB_NUMBER & ", " & DB_ISDONGLE & ", " & DB_LOCKID & ", " & DB_STATE & ", " & DB_DATE & ", " & DB_NOTE & ", " & DB_SERIALE & ")" &
@@ -269,7 +269,7 @@ Public Class NewKeyPageVM
" '" & m_LockID & "', " &
" '" & SelState.ToString() & "', " &
" '" & Format(KeyDate, "yyyy-MM-dd") & "', " &
" '" & m_Note & "', " &
" '" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "', " &
" '" & m_Seriale & "')"
End If
ManageDb.ExecuteQuery(Query)
+6 -6
View File
@@ -625,7 +625,7 @@ Public Class NewLicencePageVM
Dim textLic As String = File.ReadAllText(Path.ChangeExtension(fileName.Replace("\", "\\"), ".lic"))
If String.IsNullOrEmpty(NestKey) Or String.IsNullOrWhiteSpace(NestKey) Then
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " &
DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " &
DB_DATE & ", " & DB_LICFILE & ", " & DB_NOTE & ")" &
@@ -640,9 +640,9 @@ Public Class NewLicencePageVM
"'" & fileName.Replace("\", "\\") & "', " &
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
"'" & textLic & "', " &
"'" & m_Note & "')"
Else
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
"'" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "')"
Else
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " &
DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " &
DB_DATE & ", " & DB_LICFILE & ", " & DB_NOTE & ", " &
@@ -658,10 +658,10 @@ Public Class NewLicencePageVM
"'" & fileName.Replace("\", "\\") & "', " &
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
"'" & textLic & "', " &
"'" & m_Note & "', " &
"'" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "', " &
"'" & m_NestKey & "', " &
"Date('" & (String.Format("{0:yyyy-MM-dd}", NestDeadline)) & "')" & ")"
End If
End If
ManageDb.ExecuteQuery(Query)
Catch ex As Exception
+2 -1
View File
@@ -120,7 +120,8 @@ Public Class NewResellerPageVM
' Aggiungo un rivenditore al Db
Dim Query As String = "INSERT INTO " & DB_RESELLER &
" (" & DB_RESELLERNAME & ", " & DB_NOTE & ")" &
" VALUES ('" & m_Name & "', '" & m_Note & "')"
" VALUES ('" & m_Name & "', '" &
m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "')"
ManageDb.ExecuteQuery(Query)
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
+1 -1
View File
@@ -243,7 +243,7 @@ Public Class SearchKeyPageVM
End If
If Not String.IsNullOrWhiteSpace(Note) Then
EvalWhere(bFirstWhere, Query)
Query &= DB_NOTE & " LIKE '%" & Note & "%' "
Query &= DB_NOTE & " LIKE '%" & Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "%' "
End If
If Not String.IsNullOrWhiteSpace(Seriale) Then
EvalWhere(bFirstWhere, Query)
+3 -1
View File
@@ -322,7 +322,9 @@ Public Class UpdateKeyPageVM
End If
If Not IsNothing(Note) Then
' Aggiorno tabella Key con KeyDate scelto
Dim Query As String = "UPDATE " & DB_KEY & " SET " & DB_NOTE & " = '" & m_Note & "' WHERE " & DB_LOCKID & " = '" & Key.LockID & "' "
Dim Query As String = "UPDATE " & DB_KEY &
" SET " & DB_NOTE & " = '" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") &
"' WHERE " & DB_LOCKID & " = '" & Key.LockID & "' "
Query = Query.TrimEnd(","c, " "c)
ManageDb.ExecuteQuery(Query)
+6 -6
View File
@@ -771,7 +771,7 @@ Public Class UpdateLicencePageVM
End If
If Not IsNothing(Note) Then
EvalWhere(bFirstWhere, Query)
Query &= DB_NOTE & " = '" & m_Note & "' "
Query &= DB_NOTE & " = '" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "' "
End If
' Alla fine in ogni caso aggiorniamo anche NestKey e NestDeadline
@@ -903,7 +903,7 @@ Public Class UpdateLicencePageVM
Dim textLic As String = File.ReadAllText(Path.ChangeExtension(FilePath.Replace("\", "\\"), ".lic"))
If String.IsNullOrEmpty(NestKey) Or String.IsNullOrWhiteSpace(NestKey) Then
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " &
DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " &
DB_DATE & ", " & DB_LICFILE & ", " & DB_NOTE & ")" &
@@ -918,8 +918,8 @@ Public Class UpdateLicencePageVM
"'" & FilePath.Replace("\", "\\") & "', " &
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
"'" & textLic & "', " &
"'" & m_Note & "')"
Else
"'" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "')"
Else
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " &
DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " &
@@ -932,11 +932,11 @@ Public Class UpdateLicencePageVM
"'" & nDecOption1 & "', " &
"'" & nDecOption2 & "', " &
"Date('" & (String.Format("{0:yyyy-MM-dd}", OptionDeadline)) & "'), " &
"'" & LockID & "', " &
"'" & LockId & "', " &
"'" & FilePath.Replace("\", "\\") & "', " &
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
"'" & textLic & "', " &
"'" & m_Note & "', " &
"'" & m_Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "', " &
"'" & m_NestKey & "', " &
"Date('" & (String.Format("{0:yyyy-MM-dd}", NestDeadline)) & "')" & ")"
End If
+1 -1
View File
@@ -130,7 +130,7 @@ Public Class UpdateResellerPageVM
End If
If Not String.IsNullOrWhiteSpace(Note) Then
EvalWhere(bFirstWhere, Query)
Query &= DB_NOTE & " = '" & Note & "' "
Query &= DB_NOTE & " = '" & Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "' "
End If
Query &= "WHERE " & DB_RESELLERID & " = " & IdToUpdate
Query = Query.TrimEnd(","c, " "c)